Skip to content

Instantly share code, notes, and snippets.

@vgheo
Created March 20, 2016 17:00
Show Gist options
  • Save vgheo/f34ac7afd6447b3f1fc4 to your computer and use it in GitHub Desktop.
Save vgheo/f34ac7afd6447b3f1fc4 to your computer and use it in GitHub Desktop.
This program demonstrate that 'exit' used as keyword compiles properly, but has no effect.
/*
http://www.cplusplus.com/reference/cstdlib/exit/
https://github.com/sui77/rc-switch/pull/35/files/361888c4aef6f4c977108539ab858dd910532a41
for(unsigned int i = 1; i < numProto; i++ ) {
if (receiveProtocol(i, changeCount))
exit;
}
The "exit" line in the above code has no effect.
It is an expression of type pointer-to function ( void(*)(int) ).
*/
// included by default in Arduino
#include <cstdlib>
#include <cassert>
#include <iostream>
using namespace std;
bool flag=0;
void f() {
// nop - this is an expression of type pointer-to-function
exit;
flag=1;
}
int main() {
f();
assert(flag==1);
cout << ("PASS") << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment