GCC preprocessor and assembler files

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: utzig, lbednarz, tfAteba, barthess, RoccoMarco

Posts: 770
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 10 times
Been thanked: 122 times

GCC preprocessor and assembler files

Postby steved » Tue Aug 11, 2020 4:23 pm

Not specifically ChibiOS but I've encountered a very odd situation with preprocessor directives that maybe someone else has seen.

Symbol _USE_CHIBI_20 is passed via the command line from the makefile.

At the top of chconf.h I have the following:

Code: Select all

#define XSTR(x) STR(x)
#define STR(x) #x
#pragma message "Chibi 20 state: " XSTR(_USE_CHIBI_20)

#if defined(_USE_CHIBI_20)
#define _CHIBIOS_RT_CONF_VER_6_1_
#pragma message "Compiling for Chibi 20"

chconf.h is included into chcoreasm_v7m.S, which aborts compilation with an "invalid chconf.h" error
The #pragma message duly prints a value of 1; however the #if defined() is clearly evaluating to false.
(I have tried #ifdef _USE_CHIBI_20 and #if _USE_CHIBI_20 > 0 as well)

If I change the test to the following, everything compiles:

Code: Select all

#if defined(_USE_CHIBI_20) || defined(_FROM_ASM_)

(_FROM_ASM_ is defined in chcoreasm_v7m.S)

It seems to be odd behaviour of the defined() preprocessor directive when included from assembler. (I have tried various other combinations as well)

Has anyone come across something like this before?

Return to “General Support”

Who is online

Users browsing this forum: No registered users and 7 guests