GCC Error Message: Attempted to use the poisoned "TARGET_I386"

I modify the source code of Qemu by creating such a file

#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 defined in another header file and used in another qemu source file.

What is the meaning of this error message?

Update:

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

+6
source share
2 answers

Identifiers appear to be marked as poisoned.

From the GCC Documentation

#pragma gcc poison

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

For instance,

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

will result in an error.

If the reflected identifier appears as part of a macro extension that was determined before the identifier was poisoned, it will not result in an error. This allows you to reflect the identifier without worrying about the system headers defining the macros that use it.

For instance,

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

will not result in an error.

+11
source

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

+4
source

Source: https://habr.com/ru/post/909432/


All Articles