char ***argc problems.
1100110
10equals2 at gmail.com
Sun Aug 12 14:11:00 PDT 2012
(sorry for spam...)
On Sunday, 12 August 2012 at 21:04:55 UTC, 1100110 wrote:
> Would this be useful?
> https://github.com/1100110/OpenMPI
>
> On Sunday, 12 August 2012 at 20:52:03 UTC, Simen Kjaeraas wrote:
>> On Sun, 12 Aug 2012 22:30:57 +0200, Andrew
>> <andrew.spott at gmail.com> wrote:
>>
>>> I'm attempting to create a wrapper for MPI, however, MPI_Init
>>> wants to read the arguments for main():
>>>
>>> MPI_Init(int *argv, char ***argc);
>>>
>>> How do I get this last level of pointer reference?
>>>
>>> So far, I have:
>>>
>>> void main (string[] args)
>>> {
>>> auto argarr = new char*[args.length];
>>> foreach(i, a; args)
>>> argarr[i] = (a.dup ~ '\0').ptr;
>>>
>>> int argc = to!(int)(argarr.length);
>>> MPI_Init(&argc, argarr.ptr);
>>> }
>>>
>>> Any ideas?
>>
>>
>> // Array of pointers to command line parameters.
>> char*[] argv = args.map!((a)=>(a.dup~'\0').ptr).array;
>> // Address of first element of that array.
>> char** argvp = &argv[0];
>> // And finally, address of the pointer to that first
>> element.
>> char*** argvpp = &argvp;
>>
>> Now, the interesting part is reconstructing the string[] from
>> the potentially modified argvpp...
More information about the Digitalmars-d-learn
mailing list