Unexpected compiling/linking errors

Hi guys!

i am trying to compile some source codes in eclipse based Vitis.
Unfortunately i am getting some errors - In previous projects with the same source codes they were not present . So i suspect it got something to do with the settings (of compiler, linker..)

conflicting declaration 'typedef unsigned int uint32_t'
#define U32BIT			uint32_t
#define S32BIT			int32_t 

expected primary-expression before 'char'
#define S8BIT			char
 #define BOOLEAN		unsigned char 

Any help will be appreciated.
I don't know, but the error messages don't seem to come from the lines of code you have shown underneath.
Last edited on
Ok just to sort out:

1. Is it legal to have 2 .h files with the same line:
#define U32BIT uint32_t

in one workspace?

2. if i defined in test.h file this typedef:
typedef unsigned int U32BIT;
Can i use U32BIT expression in test.cpp file?

1. Yes
2. Yes
The "yes" answer on question 2 assumes test.cpp includes test.h.
conflicting declaration 'typedef unsigned int uint32_t'

The suggestion from this error is that uint32_t is already defined with a different definition.

Note that since C++11, uint32_t is a defined type in cstdint (which is included with most other include files) and for c, this is a defined type since C99 (defined in stdint.h> ).

You might need to comment out this definition of uint32_t.
Thanks guys 👍
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines has multiple
"Don't use macros for ..." and "Prefer ... to macros" entries.

While macros do have some uses, the rationale behind those entries are educational.

Also: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-using
"Prefer using over typedef for defining aliases"
Topic archived. No new replies allowed.