Damn you C language and all it's compilers!
-
g++ compiler considers it an error, not even a warning:
error: too many arguments to function `void MyNamespace::die()'
Run from NetBeans, via MinGW environment on Windows. Not sure about options: I use defaults.
We have covered the fact that it wont compile as C++. Call gcc directly.
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
Have fun. :) It's a very powerful too, although it does take a while to get the hang of using it effectively.
Anna :rose: Tech Blog | Visual Lint "Why would anyone prefer to wield a weapon that takes both hands at once, when they could use a lighter (and obviously superior) weapon that allows you to wield multiple ones at a time, and thus supports multi-paradigm carnage?"
Pity the site is timing out when trying to load it (tried the home page too). Will try again tonite from a different internet.
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
Pity the site is timing out when trying to load it (tried the home page too). Will try again tonite from a different internet.
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth EditionIt must be the CP effect. :doh:
Anna :rose: Tech Blog | Visual Lint "Why would anyone prefer to wield a weapon that takes both hands at once, when they could use a lighter (and obviously superior) weapon that allows you to wield multiple ones at a time, and thus supports multi-paradigm carnage?"
-
We have covered the fact that it wont compile as C++. Call gcc directly.
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Editionleppie wrote:
Call gcc directly
I just did - you are right; it gives no warnings. Sorry for misplaced post :sigh:
-
Hi! By default, if You write the prototype without any parameters in parenthesis, as in: void die() {}, then C compiler assumes that is such a function You can pass ANY number (of any type) of parameters; If You wish to have a function which will NOT receive any parameter, then, You have to write void die(void){}; (mark the word VOID in the function's parameter list) When C++ or Java is in the concern, then, the empty parenthesis mean that this is the function which does NOT accept the parameters in list; In C++ You can set void in parenthesis, but it is not mandatory. Best regards!
I would say that it is because in C, no parameter type ends up being interpreted as just an int passed in (same as if you don't specify a return type). Add in the comma operator which if memory serves correctly does something like execute each expression and return the value of the last one, and you have compiling code. So what ends up happening is something like void die(int a) { } die(3);
-
Pity the site is timing out when trying to load it (tried the home page too). Will try again tonite from a different internet.
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
The following compiles cleanly with no warnings:
void die() {}
int main()
{
die(1,2,3);
}Does not work in C++ though. Why on earth would no C compiler (linker rather) (I tested MSVC and some embedded C compiler) emit a simple warning? X|
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth EditionWild guess its related to C++ haveing overloading and it can't make a match between die with no args, and die with 3. C doesn't have overloading, so you must mean the only die declared, even if its wrong. I'm amused Alpha C gives a warning; I knew several people who worked on it... 8-)
-
The following compiles cleanly with no warnings:
void die() {}
int main()
{
die(1,2,3);
}Does not work in C++ though. Why on earth would no C compiler (linker rather) (I tested MSVC and some embedded C compiler) emit a simple warning? X|
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
The following compiles cleanly with no warnings:
void die() {}
int main()
{
die(1,2,3);
}Does not work in C++ though. Why on earth would no C compiler (linker rather) (I tested MSVC and some embedded C compiler) emit a simple warning? X|
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
The following compiles cleanly with no warnings:
void die() {}
int main()
{
die(1,2,3);
}Does not work in C++ though. Why on earth would no C compiler (linker rather) (I tested MSVC and some embedded C compiler) emit a simple warning? X|
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth EditionI agree. It's part of the language to allow that, but there should be a way to enable a warning for that. One thing that I've done successfully with C code is that I created a separate .cpp file that simply #included the corresponding .C file. That way, the .C file stayed as it is, and can be used by other tools, platform builds, etc., but on my computer, I would use a C++ compiler to build the C code so that I can get a lot more warnings, etc. In fact, I've found that to be the best way to compile C code into .NET C++/CLI, without changing the original .C file and project. That way, the C++/CLI version of the code can be easily tested using .NET unit testing tools -- but I digress.