argument-passing

Passing a byte pointer to a C# method via reverse PInvoke

亡梦爱人 提交于 2019-12-11 09:09:50
问题 In the past, I have passed a byte array from a C# method to an unmanaged C++ function. I am now trying to pass a pointer to a buffer of type unsigned char from a C++ method back into a C# method using reverse PInvoke, which uses a callback to get back to the C# code. I have tried several different ideas - like passing Ref Byte, Byte *, and IntPtr for the 2nd argument, but none of them seem to work. Here is my test code for using IntPtr: C# code: namespace TestPInvoke { class Program { static

How can I pass a class method to another function like what happen in thread constructor

亡梦爱人 提交于 2019-12-11 08:04:42
问题 I want to pass a class method to another function and I wrote these codes: class x { executeQuery(std::string query, int (*f)(void* cpuInfo, int argc, char** argv, char** azColName)) { int rc = sqlite3_exec(db, query.c_str(), &f, 0, &errMessage); ... } }; The above code shows the function that I called from class constructor! myclass() { xObject->executeQuery("test", &(myclass::myfunction)); } And this part of code shows how I pass myfunction to that method! But, during compile time I got

Array inside type array as function argument

心已入冬 提交于 2019-12-11 07:48:06
问题 I have the following program at hand program foo type bar real, dimension(2) :: vector end type type(bar), dimension(3) :: bararray call doSomething(bararray%vector) end program subroutine doSomething(v) real, dimension(3,2), intent(inout) :: v ... end subroutine Now this gives me a compilation error. Error: Two or more part references with nonzero rank must not be specified at (1) If I change the call to call doSomething((/bararray%vector(1), bararray%vector(2)/)) everything works out nicely

Scheduling child activity that implements an interface with input parameters

泄露秘密 提交于 2019-12-10 17:26:29
问题 public sealed class Parent : NativeActivity { public Parent() { Childrens = new Collection<Activity>(); Variables = new Collection<Variable>(); _currentActivityIndex = new Variable<int>(); CurrentCustomTypeInstance= new Variable<MyCustomType>(); } [Browsable(false)] public Collection<Activity> Childrens { get; set; } protected override void Execute(NativeActivityContext context) { _currentActivityIndex.Set(context, 0); context.ScheduleActivity(FirstActivity, Callback); } private void Callback

Why can an initializer-list not be used as an argument?

↘锁芯ラ 提交于 2019-12-10 15:34:54
问题 struct X { int a; int b; }; int f(X x) { return x.a + x.b; } int main() { int n = f({1, 2}); } Visual Studio 2012 (Nov CTP) reports: error C2664: 'int f(const X &)' : cannot convert parameter 1 from 'initializer-list' to 'X' Reason: cannot convert from 'initializer-list' to 'X' Only an initializer-list with zero or one elements can be converted to this type Build FAILED. 回答1: Visual Studio 2012 (Nov CTP) reports: It's not even a beta compiler. It's supposed to work. I'd link to your code

Trying to pass CGrect to performSelector withObject

亡梦爱人 提交于 2019-12-10 13:58:35
问题 I'm trying to pass a CGRect: SEL frameSel = NSSelectorFromString(@"setFrame:"); CGRect rect = CGRectMake(10, 10, 200, 100); [object performSelector:frameSel withObject:rect ]; But this does not compile I also tried: SEL frameSel = NSSelectorFromString(@"setFrame:"); CGRect rect = CGRectMake(10, 10, 200, 100); NSValue * value = [NSValue valueWithCGRect:rect]; [object performSelector:frameSel withObject:value ]; Actually, this does compile but when I debug, the frame is not setted correctly: po

Command line passing quotes within quotes

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 02:43:40
问题 I've been searching for a solution to this but couldn't find one. Not sure if its possible. Can I pass into command-line execution that passes a in a bat file which has an input file as its arguments? So from the command-line it'll look like this: C:\run.exe "C:\space folder\run.bat "C:\space folder\input.txt"" The problem is with the folders that has spaces so the quotes are required to be in there. 回答1: Try this: C:\run.exe "C:\space folder\run.bat \"C:\space folder\input.txt\"" And here is

Pass and access structures using objective-c

寵の児 提交于 2019-12-09 13:03:18
问题 I want to know how to pass structures to another function and subsequently access that structure in the called function. I'm developing for the iPhone and the reason I'm using structs is so that I can eventually pass data as structs to a server being built in C. Here's the structure: struct userInfo{ NSString *firstName; NSString *lastName; NSString *username; NSString *email; NSString *ipAddress; double latitude; double longitude; }; Here I'm simply fetching some user inputed data along with

Creating an array while passing it as an argument in Java

无人久伴 提交于 2019-12-09 02:12:26
问题 Is there a way to create an array of objects as part of a constructor or method? I'm really not sure how to word this, so I've included an example. I have an enum, and one of the fields is an array of numbers. Here is what I tried: public enum KeyboardStuff { QWERTY(1, {0.5f, 1.3f, 23.1f}, 6); DVORAK(5, {0.1f, 0.2f, 4.3f, 1.1f}, 91); CHEROKEE(2, {22.0f}, 11); private int number, thingy; private float[] theArray; private KeyboardStuff(int i, float[] anArray, int j) { // do things } } The

batch script subroutine: Passing arguments

萝らか妹 提交于 2019-12-08 15:44:48
问题 My understanding is that in order to get the date from a file passed into a subroutine as an argument, you must re-set that argument as a variable within the subroutine. Is this correct? This doesn't make since to me, so I am wondering if I do not fully understand what is going on. I can use the passed in argument in practically any other subroutine code except for date extraction. set setupEXE=setup.exe CALL :SUB_CheckCorrectDate %setupEXE% GOTO EOF ::---------------------------------- :SUB