Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Identifier Not Found error

Tags:

c++

I get identifer not found error for "startProcess":

int main(int argc, char* argv[])
{

    bool result=startProcess(argc, argv);
    return 0;
}

bool  startProcess(int argc, char* argv[])
{


}

But why?

like image 652
Ron Avatar asked Aug 23 '26 11:08

Ron


1 Answers

Functions need to be at least declared before you use them, if not defined. Try putting this at the top of your file.

bool startProcess(int argc, char* argv[]);

The above is a declaration, you're telling the compiler that at some point, you're going to provide a definition for the function, which is this:

bool  startProcess(int argc, char* argv[])
{
   code here...    
}

This difference between a declaration and a definition is important for being able to separate your code into separate files. If you had placed your definition of startProcess in a different file, the compiler would never actually see it while compiling the file that contains main. However, with the declaration, you're making a promise that it exists somewhere.

like image 106
Collin Avatar answered Aug 26 '26 00:08

Collin