Preprocessor directives.

Hi !

I would like to know if it’s possible to force an error during compilation of
code if a specific function is found, let’s say ‘strcpy(…)’.

I believe that I’ve seen something like it one before but with GCC.

In this case I’m using Watcom C++ 10.{whatever_is_the_lates}.

Best regards,
Joachim Holst

Joachim Holst <joachim.holst@obducat.com> wrote:

Hi !

I would like to know if it’s possible to force an error during compilation of
code if a specific function is found, let’s say ‘strcpy(…)’.

I believe that I’ve seen something like it one before but with GCC.

In this case I’m using Watcom C++ 10.{whatever_is_the_lates}.

Best regards,
Joachim Holst

Sure:

#define strcpy this is a bad function to use here

I’d have preferred to say:

#define strcpy #error do not use strcpy

but I’m not 100% certain – try it :slight_smile:

Cheers,
-RK

Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.