Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
My ANSI compiler complains about a mismatch when it see
My ANSI compiler complains about a mismatch when it sees
extern int func(float);
int func(x)
float x;
{ ...
✍: Guest
You have mixed the new-style prototype declaration ``extern int func(float);'' with the old-style definition ``int func(x) float x;''. It is usually possible to mix the two styles but not in this case.
Old C (and ANSI C, in the absence of prototypes, and in variable-length argument lists;`widens'' certain arguments when they are passed to functions. floats are promoted to double, and characters and short integers are promoted to int. (For old-style function definitions, the values are automatically converted back to the corresponding narrower types within the body of the called function, if they are declared that way there.) Therefore, the old-style definition above actually says that func takes a double (which will be converted to float inside the function).
This problem can be fixed either by using new-style syntax consistently in the definition:
int func(float x) { ... }
or by changing the new-style prototype declaration to match the old-style definition:
extern int func(double);
(In this case, it would be clearest to change the old-style definition to use double as well.
It is arguably much safer to avoid ``narrow'' (char, short int, and float) function arguments and return types altogether.
2016-01-13, 1286👍, 0💬
Popular Posts:
What are the core functionalities in XML .NET framework? Can you explain in detail those functionali...
How To Blend a Color Layer to a Image? - PSP Tutorials - Fading Images to Background Colors with PSP...
Can one execute dynamic SQL from Forms? Yes, use the FORMS_DDL built-in or call the DBMS_SQL databas...
What Information Is Needed to Connect SQL*Plus an Oracle Server? - Oracle DBA FAQ - Introduction to ...
Can each Java object keep track of all the threads that want to exclusively access to it?