cancel
Showing results for 
Search instead for 
Did you mean: 

#define example file on CubeIDE

JSILV.2
Senior

Does someone could point out where can I find one CubeIDE file full of complex "#define" examples? When I use more sofisticated #define into Cube IDE I receive tons of "error" messages (I mean "error message" not warnings). But into other compilers these #defines shows as perfectly correct. Could one?

10 REPLIES 10
berendi
Principal

Have you ever wondered why does the compiler display several lines of text for each error, describing the nature of it, the exact line and character position in the code where it has happened, the macros and definitions involved, their location in included files?

The plethora of information is just overwhelming the users, it would be far more helpful to display some vague quantifiers, like a handful, awful lot, or tons of errors, wouldn't it?

BTW, have you tried reading the manual?

https://gcc.gnu.org/onlinedocs/gcc-7.3.0/cpp/

JSILV.2
Senior

Dear Berendi.

Thanks, the manual is always useful.

But I am guessing that I am facing a problem that seems, in fact, is not into the sentence's sintax, because I receive one error in some lines and two lines later a copy of the same line never arise as error. If I fix those erros using some bizarre, non sense measures like adding parentesis, for example, I quit the error messages but some warning remain. And, the more strange, in this situation if I issue BULD again (issuing twice) all erros and warnings vanishes. So, I must ask: if the compiler perceived warnings in those lines, why Building twice those warning become nothing? How the compile decides that "at this turn" this is not a warning anymore...

What I am doing wrongly? Someone could answer?

Regards,

Pavel A.
Evangelist III

> why Building twice those warning become nothing? 

Because with warnings, the object file is produced and the compiler won't touch the .c file again (until you make changes).

With errors, object file is not produced and the compiler will try to compile it again, and will show same messages again.

> What I am doing wrongly? Someone could answer?

You haven't shown us the exact error messages, neither the "more sophisticated" defines that you've added.

-- pa

JSILV.2
Senior

Dear Pavel. Thanks for your answer.

I perceived that issuing the BUILD twice, after the first time with some wanings messages, the second time raises with ZERO warnings, how could it possible for something with warning suddenlly vanishes?

The more sophisticated #define are that which depends on #defines before. On several equivalent lines the compile shows error in one line and in some others before and after there is not error. How could it be possible? Should I add some compilation switch option?

This CUBEIDE into my Windows 10 shuts off several times in one debug section. I changed the "compatibility options" on the operanting system but we did not have the solution. Could someone knows how could we use this CUBEIDE without this issue?

Regards,

S.Ma
Principal

It depends on what you want to do with #define

For the preprocessor, it is a simple text find and replace operation before compilation, with the possibility to make the code more complex to read with non intuitive macros. The #define must be in place BEFORE it is used. This is the tricky #include "*.h" sequence dependency...

If you use #define for values, then use enum{} as your values will show as text in the debug watch window.

If you open watch window and inspect a GPIO port, which one you prefer to read: 0x40002860 or GPIOB ?

> how could it possible for something with warning suddenlly vanishes?

Pavel already explained it to you!

And you still haven't shown any error or warning text...

JSILV.2
Senior

Dear All.

Thanks for your kind answer. I will try to build one simple yet representative explanation of my problem.

Regards,

Jorge

Instead you could just post the text of the first build error!

Dear Sir.

Is there a *log file into CUBEIDE where we could see any MACRO EXPANSION from our source file?

Regards,