2

I'm trying to use cpp (ANSI-C preprocessor) to preprocess some non ANSI-C files.

These files contain assembly instruction in PicoBlaze syntax. PicoBlaze uses 'd to annotate the literal's radix. I would like to preprocess my files with cpp.

I get several:

<stdin>:228:163: warning: missing terminating ' character [enabled by default]
<stdin>:257:98: warning: missing terminating ' character [enabled by default]
...

warnings. How can I disable termination character checks for ' (or all characters) in cpp?

Here is my command line call:

cpp.exe -E main_Page0.psm
Paebbels
  • 15,573
  • 13
  • 70
  • 139
  • I'm not posting as an answer since I don't know this is authoritative, but you're specifically attempting to use an ANSI-C compliant preprocessor to handle non-ANSI compliant files... I do not believe that there is an option to do what you are trying to do. This may be a perfect job for a tool like sed. – David Hoelzer May 11 '15 at 13:11
  • @DavidHoelzer If I understood the warning correctly, cpp is missing the closing `'` character after `ADD Reg0, 01'd`. Why does the preprocessor check lines for such character? This shouldn't be a concern for a pre processor ... – Paebbels May 11 '15 at 13:26
  • 2
    @paebbels: The preprocessor should not expand macro names inside quoted strings or character literals, so it must understand quoting syntaxes. (eg. even if `d` were a macro, `'d'` is still the character literal `'d'`. And sorry for the late reply. – rici May 26 '15 at 00:13

1 Answers1

1

I think I found a solution by myself, but I'm still open for other suggestions.

Solution 1)
-w disables all warnings -> dissatisfying

Suppress all warnings, including those which GNU CPP issues by default.
GCC Manual (v4.9.2) -> page 158

Solution 2)
-x assembler-with-cpp sets cpp's source language to assembly.
Default language is ANSI-C, if the file extension is unknown (equals -x c).

Specify the source language: C, C++, Objective-C, or assembly. This has nothing to do with standards conformance or extensions; it merely selects which base syntax to expect. If you give none of these options, cpp will deduce the language from the extension of the source file: ‘.c’, ‘.cc’, ‘.m’, or ‘.S’. Some other common extensions for C++ and assembly are also recognized. If cpp does not recognize the extension, it will treat the file as C; this is the most generic mode.
GCC Manual (v4.9.2) -> page 160

Paebbels
  • 15,573
  • 13
  • 70
  • 139