Timeline for m3ph1st0s's programming puzzle 1 (C++)
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 21, 2014 at 1:26 | comment | added | dan04 |
It may be UB, but several popular compilers support it anyway. I've done #define int ERROR to force myself to use the equivalent of int32_t instead of built-in types. By the time I got around to int main() , I had forgotten about the macro and wondered why the heck my code wouldn't compile.
|
|
Jun 20, 2014 at 23:15 | comment | added | bacchusbeale | I tried this. It works as long as it is defined after int main(). | |
Oct 2, 2012 at 5:10 | comment | added | bartolo-otrit | @Dan In such case it works, sorry. | |
Oct 1, 2012 at 18:43 | vote | accept | Bogdan Alexandru | ||
Oct 1, 2012 at 13:44 | comment | added | Dan | You'd have to make it the first line of your main, after main is defined... | |
Oct 1, 2012 at 6:23 | comment | added | bartolo-otrit |
should work as well and is the same length error: '::main' must return 'int' (minGW 4.4) but #define float int works fine
|
|
Sep 28, 2012 at 20:46 | comment | added | sehe | @DeadMG Well, it doesn't forbid it, as the standard does not forbid UB. But you end up with undefined behaviour... | |
Sep 28, 2012 at 20:16 | comment | added | DeadMG | @Dan: The C++ Standard forbids it. | |
Sep 28, 2012 at 20:07 | comment | added | Dan | Fred, can you cite your sources? The GCC cpp docs say "You may define any valid identifier as a macro, even if it is a C keyword." | |
Sep 28, 2012 at 20:03 | comment | added | fredoverflow |
#define int float is actually undefined behavior. You are not allowed to give keywords new meaning.
|
|
Sep 28, 2012 at 19:41 | comment | added | Bogdan Alexandru | this is what I had in mind when I first came with the idea | |
S Sep 28, 2012 at 15:29 | review | Low quality posts | |||
Sep 28, 2012 at 18:49 | |||||
S Sep 28, 2012 at 15:29 | review | First posts | |||
Oct 8, 2012 at 16:18 | |||||
Sep 28, 2012 at 15:26 | history | answered | Dan | CC BY-SA 3.0 |