Thread: (argc, argv) C++ & Prolog

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    26

    (argc, argv) C++ & Prolog

    My question is concerning argv[0].

    I know (in theory) that on Unix, this argument passes the part of the command-line that is used to locate the executable. Prolog uses this to find the file holding the running executable.

    I also know that on Windows, this argument is used to find a module of the running executable. But I can't figure out what to assign to argv[0] when I am writing a similar program to a Unix version.

    Basically, I have a bunch of header and source files that run using a makefile (on Unix). The makefile facilitates the execution and also the communication between the various Prolog and C++ programs. I am trying to achieve the same thing by using VS2008 IDE (Windows). In other words, I am upgrading the same system to be able to run using Visual Studio 2008 IDE.

    In one of the C++ files that gets Prolog and C++ to talk to each other, I have:

    argv[0] = "a.out";
    PL_initialise(1, argv);

    So when in Unix I type a.out at the prompt, it invokes the makefile and they all run. What should I use instead of argv[0] = "a.out" to achieve the same goal?

    Appreciate any pointers,

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Why do you need to set argv[0] at all? The correct value is passed to the program by the OS at runtime; you should not need to set it.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. argc, argv
    By Martas in forum C Programming
    Replies: 6
    Last Post: 11-19-2009, 09:39 AM
  2. Using argc and argv data
    By Rad_Turnip in forum C Programming
    Replies: 4
    Last Post: 03-31-2006, 06:09 AM
  3. Converting a argc / argv construct into a va_list
    By chambece in forum C Programming
    Replies: 6
    Last Post: 07-03-2005, 04:47 PM
  4. argc & argv
    By miryellis in forum C Programming
    Replies: 11
    Last Post: 09-19-2004, 11:59 PM
  5. how do i? re: argc - argv
    By luigi40 in forum C Programming
    Replies: 2
    Last Post: 06-11-2004, 10:17 AM

Tags for this Thread