forcing a compile time error

From: Michael Gaab (mike-g_at_montana.com)
Date: 11/08/03


Date: Sat, 8 Nov 2003 09:40:07 -0600

How would I force the compiler to throw an error for the following:

function signature -
void foo(short);

function call -
foo('d');

My compiler does not complain when I call foo() with a character argument.
I am assuming that the compiler does some type casting or that char's are
interpreted as a byte. Not exactly sure.

At any rate how do I force the compiler throw a error?

thanks, Mike



Relevant Pages

  • Re: Differences between C and C++
    ... it is really no different than misusing a "void *" pointer. ... one can do it, and the compiler wont complain, but it is the programmers' problem is the behavior is not what was expected, rather than that the compiler didn't give a complaint about it. ... the declaration a prototype and forces the implementation to diagnose ...
    (comp.lang.c)
  • Re: forcing a compile time error
    ... > function signature - ... > void foo; ... > My compiler does not complain when I call foowith a character argument. ... condition in the template to cause a compile time ...
    (comp.lang.cpp)
  • Re: forcing a compile time error
    ... > function signature - ... > void foo; ... > My compiler does not complain when I call foo() with a character argument. ...
    (comp.lang.cpp)
  • Re: gcc bug ?
    ... shall only appear in a function whose return type is void. ... return f; is a syntax error. ... either way, the compiler must complain. ...
    (comp.lang.c)
  • Re: access(FULLPATH, xxx);
    ... with "trial& error" to just silence the compiler. ... void *foo); ... given that the language in the specification _was_ abiguous and both ... documentation was paramount. ...
    (freebsd-questions)