P
pauldepstein
#include <iostream>
using namespace std;
int main()
{
extern "C" int f(int, int);
cout << f(2,3);
cin.get();
}
int f(int x, int y)
{return (x* 234);}
Using Dev C++ with Windows XP, the above code would not compile. The
error messages were: syntax error before string constant and f
undeclared.
This puzzles me somewhat as it seems quite a faithful rendering of the
extern C section of the C++ primer 4th edition.
What am I missing?
It is correct that this use of extern C is completely redundant because
the code has no features that are unique to C or unique to C++.
However, that doesn't seem a likely reason for the compiler to
complain.
The whole reason I got into this extern C business is that I wanted to
use the C facility of suspending type-checking for function parameters
using the (...) notation.
However, I couldn't get this to work. If someone can help me with
this, I would be grateful. C++ primer seems to imply that c++ already
supports this ellipsis notation but I didn't find it straightforward.
Thank you very much for your help.
Paul Epstein
using namespace std;
int main()
{
extern "C" int f(int, int);
cout << f(2,3);
cin.get();
}
int f(int x, int y)
{return (x* 234);}
Using Dev C++ with Windows XP, the above code would not compile. The
error messages were: syntax error before string constant and f
undeclared.
This puzzles me somewhat as it seems quite a faithful rendering of the
extern C section of the C++ primer 4th edition.
What am I missing?
It is correct that this use of extern C is completely redundant because
the code has no features that are unique to C or unique to C++.
However, that doesn't seem a likely reason for the compiler to
complain.
The whole reason I got into this extern C business is that I wanted to
use the C facility of suspending type-checking for function parameters
using the (...) notation.
However, I couldn't get this to work. If someone can help me with
this, I would be grateful. C++ primer seems to imply that c++ already
supports this ellipsis notation but I didn't find it straightforward.
Thank you very much for your help.
Paul Epstein