I implemented a function called abs(). I get this error:
Intrinsic function, cannot be defined
What have I done wrong? I'm using Visual Studio 2005.
I implemented a function called abs(). I get this error:
Intrinsic function, cannot be defined
What have I done wrong? I'm using Visual Studio 2005.
The problem is not being in a header or not.
The problem is that intrinsic functions, i.e., functions that the compiler recognizes and implements itself, generally with optimizations that wouldn't be available in C code alone, cannot be defined.
The names of all mathematical functions (see math.h)
The names of all mathematical functions prefixed by 'f' or 'l'.
Are reserved for the implementation.
Intrinsic function, cannot be defined
In this case, intrinsic means that the compiler already has an implementation of a function called abs
, and which you cannot redefine.
Solution? Change your function's name to something else, snakile_abs
for example.
Check the MSDN documentation on the abs
function for more information.
Defining static int abs(int x) { ... }
should be legal, but simply int abs(int x) { ... }
has undefined behavior, and thus one reasonable thing a compile could do is issue an error.