Author Topic: Which project template to choose for the given code snippet?  (Read 2910 times)

Offline asd34

  • Multiple posting newcomer
  • *
  • Posts: 27
Which project template to choose for the given code snippet?
« 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)
{
}

Offline Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Which project template to choose for the given code snippet?
« Reply #1 on: April 03, 2013, 03:51:28 pm »
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?

Offline asd34

  • Multiple posting newcomer
  • *
  • Posts: 27
Re: Which project template to choose for the given code snippet?
« Reply #2 on: April 03, 2013, 04:17:14 pm »
Quote
s it you who will write the main() or is it some macro in your code who will do it?
Supposed to be me.

Quote
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,

Offline Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Which project template to choose for the given code snippet?
« Reply #3 on: April 03, 2013, 05:28:32 pm »
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).

zabzonk

  • Guest
Re: Which project template to choose for the given code snippet?
« Reply #4 on: April 03, 2013, 05:32:04 pm »
Quote
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".

Quote
In C++, **argv isn't the same as *argv[]

It is when used as a function parameter (as here) - the two are identical.