cyfdecyf
cyfdecyf

Reputation: 836

GCC error message: attempt to use poisoned "TARGET_I386"

I'm modifying Qemu's source code, created a file like this

#if defined(TARGET_I386)
    /* some defines */
#elif defined(TARGET_ARM)
    /* some other defines */
#endif

This file is then included in vl.c, and gcc reports the following error message:

error: attempt to use poisoned "TARGET_I386"
error: attempt to use poisoned "TARGET_ARM"

TARGET_I386 is defined in another header file and is used in other qemu's source file.

What's the meaning of this error message?

Update:

As mentioned by Matthias Werner, these defines should not be used for target independent code. These poison identifies are defined in poison.h

Upvotes: 9

Views: 7977

Answers (2)

Matthias
Matthias

Reputation: 8180

Poison identifiers in QEMU should not be used when building target independent code.

Upvotes: 9

r_ahlskog
r_ahlskog

Reputation: 1966

Apparently the identifiers have been marked as poisoned

From GCC Documentation

#pragma GCC poison

Sometimes, there is an identifier that you want to remove completely from your program, and make sure that it never creeps back in. To enforce this, you can poison the identifier with this pragma. #pragma GCC poison is followed by a list of identifiers to poison. If any of those identifiers appears anywhere in the source after the directive, it is a hard error.

For example,

#pragma GCC poison printf sprintf fprintf
sprintf(some_string, "hello");

will produce an error.

If a poisoned identifier appears as part of the expansion of a macro which was defined before the identifier was poisoned, it will not cause an error. This lets you poison an identifier without worrying about system headers defining macros that use it.

For example,

#define strrchr rindex
#pragma GCC poison rindex
strrchr(some_string, 'h');

will not produce an error.

Upvotes: 18

Related Questions