digitalmars.D.learn - char ***argc problems.
- Andrew (15/15) Aug 12 2012 I'm attempting to create a wrapper for MPI, however, MPI_Init
- Simen Kjaeraas (11/25) Aug 12 2012 // Array of pointers to command line parameters.
- 1100110 (5/20) Aug 12 2012 Would this help?
- Andrew (3/29) Aug 12 2012 Yes, incredibly.
- 1100110 (2/2) Aug 12 2012 Let me know if you see something weird, I haven't tried building that in...
- 1100110 (5/31) Aug 12 2012 Also the Elementary repo has a wrapper for main() from E17, might be
- Andrej Mitrovic (9/11) Aug 12 2012 You know.. it'd be much simpler if argc & argv were stored somewhere.
- Simen Kjaeraas (5/16) Aug 12 2012 That don't sound too stupid. File an enhancement request, wouldya?
- Andrej Mitrovic (2/3) Aug 12 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8544
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? -Andrew
Aug 12 2012
On Sun, 12 Aug 2012 22:30:57 +0200, Andrew <andrew.spott 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... -- Simen
Aug 12 2012
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 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...
Aug 12 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 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...
Aug 12 2012
Would this help? https://github.com/1100110/OpenMPI On Sun, 12 Aug 2012 15:30:57 -0500, Andrew <andrew.spott 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? -Andrew-- Using Opera's revolutionary email client: http://www.opera.com/mail/
Aug 12 2012
Yes, incredibly. Thanks! On Sunday, 12 August 2012 at 20:57:47 UTC, 1100110 wrote:Would this help? https://github.com/1100110/OpenMPI On Sun, 12 Aug 2012 15:30:57 -0500, Andrew <andrew.spott 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? -Andrew
Aug 12 2012
Let me know if you see something weird, I haven't tried building that in a long time.
Aug 12 2012
Also the Elementary repo has a wrapper for main() from E17, might be useful. On Sun, 12 Aug 2012 15:54:45 -0500, 1100110 <10equals2 gmail.com> wrote:Would this help? https://github.com/1100110/OpenMPI On Sun, 12 Aug 2012 15:30:57 -0500, Andrew <andrew.spott gmail.com> wrote:-- Using Opera's revolutionary email client: http://www.opera.com/mail/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? -Andrew
Aug 12 2012
On 8/12/12, Simen Kjaeraas <simen.kjaras gmail.com> wrote:// Array of pointers to command line parameters. char*[] argv = args.map!((a)=>(a.dup~'\0').ptr).array;You know.. it'd be much simpler if argc & argv were stored somewhere. druntime/src/rt/dmain2.d is where the action begins: extern (C) int main(int argc, char** argv) { ... } And then this is stored as a string[] to _d_args which can be picked up via Runtime.args() in core.runtime. I'm thinking that having to retrieve the original argc/argv is common when interfacing with C/C++, so maybe we should have a druntime function which can return the original unprocessed args?
Aug 12 2012
On Sun, 12 Aug 2012 23:02:43 +0200, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:On 8/12/12, Simen Kjaeraas <simen.kjaras gmail.com> wrote:That don't sound too stupid. File an enhancement request, wouldya? -- Simen// Array of pointers to command line parameters. char*[] argv = args.map!((a)=>(a.dup~'\0').ptr).array;You know.. it'd be much simpler if argc & argv were stored somewhere. druntime/src/rt/dmain2.d is where the action begins: extern (C) int main(int argc, char** argv) { ... } And then this is stored as a string[] to _d_args which can be picked up via Runtime.args() in core.runtime. I'm thinking that having to retrieve the original argc/argv is common when interfacing with C/C++, so maybe we should have a druntime function which can return the original unprocessed args?
Aug 12 2012
On 8/12/12, Simen Kjaeraas <simen.kjaras gmail.com> wrote:That don't sound too stupid. File an enhancement request, wouldya?http://d.puremagic.com/issues/show_bug.cgi?id=8544
Aug 12 2012