externen Verweis (keine lib), missing binary operator

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

externen Verweis (keine lib), missing binary operator

1,409 Views
software_entwic
Contributor I

English:

I use an external reference to a global data in my project collection (no lib). If I want to use a #define in a #if a == x (external define) an error missing comes binary operator. What can I do about it?
Deutscher Orginaltext:

Ich benutze in meinem Projekt einen externen Verweis auf eine globale Daten Sammlung(keine lib).

Wenn ich eine #define benutzen möchte in einem

#if (a == x(externer define))

kommt ein Fehler Missing binary Operator.

Was kann ich dagegen tun?

Labels (3)
0 Kudos
5 Replies

893 Views
software_entwic
Contributor I

In the same file it works, but I must used an external File who it is implemented. By the external reference LPCXpresso make this error, and I don't know why.

this file is one of the first includes, after the system (<string.h> ...) libs.

1) system libs

2) data types

3) this file

4) other def

But I look again the order of this includes.

Best Regards,
Andreas Kullick

0 Kudos

893 Views
software_entwic
Contributor I

the construction:

global_data_collection.PNG

Best Regards,
Andreas Kullick

0 Kudos

893 Views
avt
Contributor III

There is no problem with what you are trying to do. For example, this (all in a single file) works as you would expect:

#define _ON 1

#define MY_VAR _ON

#if MY_VAR == _ON

#warning ON

#else

#warning OFF

#endif

So, I can only assume that you have something wrong with your #includes. In your diagram above, does your "Using" box know about the "Predefined" box above it?

0 Kudos

893 Views
avt
Contributor III

C (and C++) pre-processor comparisons only works on integers, not strings. Maybe you could explain what you are trying to achieve?

0 Kudos

893 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Andreas,

The preprocessor does not know anything about types in the language, so it cannot cast the macro _ON inside the if expression. The `#if' directive will carry out all calculations in the widest integer type known to the compiler; on most machines supported by GCC this is 64 bits.

Could you give us more information on what you are trying to achieve?


Hope it helps!

Best Regards,
Carlos Mendoza
Technical Support Engineer

0 Kudos