Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: asd34 on April 03, 2013, 02:49:05 pm
-
Dear All,
I find it a bit difficult to spot which project template I must choose from CB IDE if I got the following syntax in the source code .
It looks like a C or C++ but none of templates in CB has a similar type of main function body(bolded) as shown below.
I kindly ask for your help?
#include <petscksp.h>
#undef __FUNCT__
#define __FUNCT__ "main"
int main(int argc,char **args)
{
}
-
More info needed. Is it you who will write the main() or is it some macro in your code who will do it? Do you have access to the macro? Do you have access to the #define?
-
s it you who will write the main() or is it some macro in your code who will do it?
Supposed to be me.
Do you have access to the macro? Do you have access to the #define?
No, it's just an example which supposed to be run on Winx32 platform.
Does it really matters all of this? because from programmatic point of view I would say that
there is just a mistypo at the main function definition. Just change the arguments in the caller
function should work. But intuitively I'm sure that CB configures something at the background in
machine language level (resources, etc...) or probably I'm wrong.
regards,
-
In "plain C", **argv and *argv[] is the same so that your declaration of main() is an ordinary definition of main(). You can start writing your main(). Note that, under windows, you should write WinMain() instead of a DOS type main().
In C++, **argv isn't the same as *argv[] (stronger type checking) even if it is the same internally. If you need to pass **argv, use reinterpret_cast<char **>(argv).
-
Note that, under windows, you should write WinMain() instead of a DOS type main().
Not unless you are writing a Windows gui app. Windows command line applications should use main() - and there is no "DOS".
In C++, **argv isn't the same as *argv[]
It is when used as a function parameter (as here) - the two are identical.