| #include <stdlib.h> |
| #include <stdio.h> |
| #include <springbok_intrinsics.h> |
| #include <springbok.h> |
| |
| class ExampleStatic { |
| public: |
| ExampleStatic() { |
| springbok_simprint_error("Hello pre-main C++ world.", 0); |
| value = 1279; |
| } |
| |
| ~ExampleStatic() { |
| springbok_simprint_error("Goodbye pre-main C++ world.", 0); |
| } |
| |
| unsigned int value; |
| }; |
| |
| ExampleStatic exampleStatic; |
| |
| extern "C" __attribute__((constructor)) void boop(void) { |
| springbok_simprint_error("Hello pre-main C world.", 0); |
| } |
| |
| extern "C" __attribute__((destructor)) void beep(void) { |
| springbok_simprint_error("Goodbye pre-main C world.", 0); |
| } |
| |
| extern "C" void blerp(void) { |
| springbok_simprint_error("Fare thee well, atexit.", 0); |
| } |
| |
| extern "C" int main(void) { |
| static char thingy[10] = {13, 14, 15, 16}; |
| |
| atexit(blerp); |
| |
| printf("%s(%d): Hello printf!\n", __PRETTY_FUNCTION__, __LINE__); |
| |
| const float sorta_pi = 3.141592653589f; |
| int chars_needed = float_to_str(0, NULL, sorta_pi); |
| char *buffer = new char[chars_needed]; |
| float_to_str(chars_needed, buffer, sorta_pi); |
| printf("Pi is ~%s, %d characters printed\n", buffer, chars_needed); |
| delete[] buffer; |
| |
| return thingy[0] + thingy[1] + thingy[2] + thingy[3] + exampleStatic.value; |
| } |