Hello Everybody.

I'm with a classic problem in C preprocessor concatenation.
This is the situation:

#define BAUDRATE(VAL)   (B ## VAL)
//...
const uint32_t BAUDRATE_VAL[] = {1200, 2400, 9600};
//...
br = BAUDRATE(BAUDRATE_VAL[i]);
//...

This code, result in the error: BBAUDRATE_VAL undeclared

I need that the result of concatenation be: B1200, B2400, B9600, ...

Thanks.

I need that the result of concatenation be: B1200, B2400, B9600, ...

How do you expect to get the runtime value of BAUDRATE_VAL at compile time?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.