A few questions about the C ++ preprocessor:

A few questions about the C ++ preprocessor:

  • How to force the preprocessor to jump to a new line in the preprocessing code?
  • How to force the preprocessor to insert a tab character or several spaces in the preprocessing code?
  • how to make a preprocessor embed comments in preprocessing code?
-3
c ++ c-preprocessor
Oct 24 '10 at 10:28
source share
5 answers

1) use backslash as Tim pointed out

2) I do not think you can

3)

#define COMMENT /##/ this is a comment #define CPPCOMMENT(c) /##/ c #define CCOMMENT(c) /##* c *##/ COMMENT CPPCOMMENT(This is a c++ comment) CCOMMENT(This is ac comment) 

Edit

2 Reservations

1) Does not work in all compilers.

2) Do not do this, this is stupid.

+1
Oct 24 '10 at 10:52
source share

As for No. 3, it is the responsibility of the preprocessor to remove comments from the code; I do not think that this allowed them to be left. In any case, it will be a flag specific to the C ++ compiler you use to indicate your environment.

+5
Oct 24 '10 at 10:33
source share

Questions 2) and 3) do not make much sense, as other people have outlined.

Regarding question 1, I assume that you are referring to multi-line macros, which can be done as follows:

 #define FOO line 1 \ line 2 \ line 3 \ ... \ line n 

Pay attention to the missing \ on the last line!

+4
Oct 24 '10 at 10:41
source share

How to make the preprocessor go to a new line in the preprocessing code?

Why?

how to make a preprocessor insert a tab character or a few spaces in the preprocessing code?

Why?

how to make a preprocessor embed comments in preprocessing code?

Why?

The preprocessor is a pre processor; it is started before the code is converted to machine code. Spaces and comments that you want to add will not affect the output of the application.

If you are trying to control the output of gcc -E or something similar, you bark the wrong tree.

+2
Oct 24 '10 at 10:34
source share

You are doing it wrong ... PREPROCESSOR is not for this purpose.

+2
Oct 24 '10 at 10:35
source share



All Articles