gcc poison pragma

Useful when you want to get rid of C calls that should not be used because they are unsafe, like strcpy or sprintf: GCC's pre-processor allows you to mark a function as poisonous, causing calls to it to become a compile time error:



#include <string.h>
#include <stdio.h>

#pragma GCC poison strcpy

int main()
{
char t[5];
strcpy(t, "A");
printf("Hello World\n");
}





cristi:~ diciu$ gcc strcpy.c
strcpy.c:10:2: error: attempt to use poisoned "strcpy"
cristi:~ diciu$