question about code comment

E

Ethan Meyers

Hi everyone,
I want to handle the "/* */" style comment in a file, for example,
there are two programs in a file:
int main()
{int x;return 0;}
int main()
{int y;return 0;}
How to use other preprocess to comment out one of the main() rather
than using "/* */"?
If there are more code segments, is your solution still applicable?
 
R

Robert Harris

Ethan said:
Hi everyone,
I want to handle the "/* */" style comment in a file, for example,
there are two programs in a file:
int main()
{int x;return 0;}
int main()
{int y;return 0;}
How to use other preprocess to comment out one of the main() rather
than using "/* */"?
If there are more code segments, is your solution still applicable?
Ugh! You need two files!

Robert
 
U

Ulrich Eckhardt

Ethan said:
I want to handle the "/* */" style comment in a file, for example,
there are two programs in a file:
int main()
{int x;return 0;}
int main()
{int y;return 0;}
How to use other preprocess to comment out one of the main() rather
than using "/* */"?

I can only guess what you want, your question is slightly unclear. You can
use preprocessor conditionals and configure your compiler via the
commandline so it selects the right part of code. Those are the most
simply and most often used parts, sure you can find some documentation.
If there are more code segments, is your solution still applicable?

Understand it and judge yourself. ;)

Uli
 
E

Emmanuel Delahaye

Ethan Meyers a écrit :
Hi everyone,
I want to handle the "/* */" style comment in a file, for example,
there are two programs in a file:
int main()
{int x;return 0;}
int main()
{int y;return 0;}
How to use other preprocess to comment out one of the main() rather
than using "/* */"?
If there are more code segments, is your solution still applicable?

#if 0 /* 0 or 1 */
int main()
{int x;return 0;}
#else
int main()
int y;return 0;}
#endif
 
E

Ethan Meyers

Ulrich said:
I can only guess what you want, your question is slightly unclear. You can
use preprocessor conditionals and configure your compiler via the
commandline so it selects the right part of code. Those are the most
simply and most often used parts, sure you can find some documentation.
I will pay more attention to the usage of preprocessor conditionals.
But i can't figure out how to configure compiler via the cmdline and
select the right part of code. Can you post some messages on that
topic, or email me privately.
 
F

Flash Gordon

Ethan said:
I will pay more attention to the usage of preprocessor conditionals.
But i can't figure out how to configure compiler via the cmdline and
select the right part of code. Can you post some messages on that
topic, or email me privately.

How to define macros from the command line is dependant on the compiler,
so either read it's manual or ask on a group dedicated to the compiler
in question.

<OT>
Often -D<definition> can be used
</OT>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top