Would the following determine if the bit pattern for
floating point 0.0 and integer 0 are the same?
#include <stdio.h>
int main(void)
<%
if(0 == 0.0f)
puts("Bit pattern is the same.");
return 0;
%>
Also is it undefined behavior for failure
to include the proper header file for any
function or just functions that accept a
variable number of arguments?
Mike already answered your first question, he was a little unsure
about the second.
It is not and has never been a requirement in C that you include
header files, except in a few cases where data types with
implementation-defined types and members (such as time_t, FILE, etc.).
Prior to the current (1999) standard you did not need a prototype or a
declaration to call a function that returned int and accepted a fixed
number and type of arguments, if all the argument types were those
provided by default promotions.
Under the current standard, there must be at least a declaration in
scope for any function you call, specifying the return type. Implicit
int is illegal, including the return type of functions. The
declaration does not need to be a prototype if the function accepts a
fixed number and type of arguments if the types are the default
promotions.
Since the very first 1989 ANSI standard, it produces undefined
behavior to call a variadic function without a full prototype in
scope.
It is perfectly valid under all versions of the C standard to provide
your own prototype for a standard function so long as you get it
correct.
If you write a prototype equivalent to:
char *strchr(const char *s, int c);
....then you can call this function without including <string.h>.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq