1

During the compilation of a C file I used idirafter flag to mention the directory to look if it does not find the file in any of the locations mentioned using -I. To simulate the problem I have written a small sample program which is as below.

I am not sure why, when CLI_CONFIGURE_MODE expands, there is a new line added before and after the symbol. If anyone can help me out then it will be really helpful.

Include file: sample.h

#define CLI_CONFIGURE_MODE "/exec/configure"

Test C file: sample.c

#include "sample.h"    
#define FORM(cmdstr,modestr) command cmdstr; mode modestr; should be in previous line
    FORM("dummy_command" , CLI_CONFIGURE_MODE) 

Snippet of preprocessor output of the file:

define __DECIMAL_BID_FORMAT__ 1     
# 1 "<command-line>"     
# 1 "waste.c"     
# 1 "../waste_include/waste.h" 1 3 4     
#define CLI_CONFIGURE_MODE "/exec/configure"     
# 2 "waste.c" 2     

#define FORM(cmdstr,modestr) command cmdstr; mode modestr; should be in previous line

    command "dummy_command"; mode    
    # 5 "waste.c" 3 4     
    "/exec/configure"    
    # 5 "waste.c"     enter code hereenter code here
    ; should be in previous line

Command line used to compile the file:-

x86_64-wrs-linux-gcc -idirafter../waste_include -E -dD waste.c > 1
Thomas Fritsch
  • 9,639
  • 33
  • 37
  • 49
Srijith
  • 11
  • 1
  • I've improved formatting (for easier reading and understanding). – Thomas Fritsch Oct 08 '17 at 17:39
  • 1
    Why is this a problem? – melpomene Oct 08 '17 at 17:42
  • I understand in a normal C program compilation the new line really doesnt matter. But I was using the preprocessor to expand on all the macros and use the preprocessor output to implement something at work. It worked fine with 4.6.3 compiler but when i had to port it to 5.2.0, I am facing this issue. – Srijith Oct 09 '17 at 17:36

0 Answers0