|
#11
|
||||
|
||||
![]()
The second option sounds simple enough. If matters on the branch weighing are handled appropriately, checking if the address is invalid should be a very miniscule cut by assuming that the validity of the address is by far the most likely branch case. However the Microsoft compiler seems to override that concept at times.
![]() I have no idea what SEH is. The third option would be the sexiest. Function-oriented templating is always a bit more 1:1 translatable to the human concept, but I would always avoid laying a series out except for cases where the conditional operations were too large or too complex to maintain in the local scope. Also, I think that writing any code for portability, is a plus anywhere, not just GNU/Linux. Linux would be a prime example for targeting portability, but keeping code simplicity and purity as a general rule of thumb should suffice over the need of targeting any default operating system.
__________________
http://theoatmeal.com/comics/cat_vs_internet |
#12
|
||||
|
||||
![]()
The port to Linux will facilitate a port for Android, Zilmar can raise money with a version for Android on google market.
|
#13
|
||||
|
||||
![]() Quote:
-------------
__________________
CPU:Intel Xeon x5690 @ 4.2Ghz, Mainboard:Asus Rampage III Extreme, Memory:48GB Corsair Vengeance LP 1600
Video:EVGA Geforce GTX 1080 Founders Edition, NVidia Geforce GTX 1060 Founders Edition Monitor:ROG PG279Q, BenQ BL2211, Sound:Creative XFI Titanium Fatal1ty Pro SDD:Crucial MX300 275, Crucial MX300 525, Crucial MX300 1000 HDD:500GB Spinpoint F3, 1TB WD Black, 2TB WD Red, 1TB WD Black Case:NZXT Phantom 820, PSU:Seasonic X-850, OS:Windows 7 SP1 |
#14
|
||||
|
||||
![]() Quote:
Quote:
In fact, I'm not really seeing anything that the C++ try { } catch { } finally { } model is doing that the standard C approach of setting a signal ("exception") handler and doing a longjmp() when raised isn't.
__________________
http://theoatmeal.com/comics/cat_vs_internet |
#15
|
||||
|
||||
![]()
I wrote a program to dereference user-defined pointer ranges, that would constantly cause an access violation or a segmentation fault.
It goes something like: Code:
#include <signal.h> #include <setjmp.h> int main() { ... signal(SIGSEGV, exception_handler); for (i = 0; addr_start + i <= addr_end; i++) { unsigned char memory_byte; int recovered_from_exception; printf("RAM[0x%lX]: ", addr_start + i); recovered_from_exception = setjmp(exc_pt); if (recovered_from_exception) { signal(SIGSEGV, exception_handler); /* Reschedule the handler. */ continue; /* Move on to the next byte of memory in loop. */ } memory_byte = *(unsigned char *)(addr_start + i); /* segfault likely */ printf("0x%02X (%c)\n", memory_byte, memory_byte); } void exception_handler(int parameter) { fprintf(stderr, "Exception caught (signal %i).\n", parameter); longjmp(exc_pt, parameter); }
__________________
http://theoatmeal.com/comics/cat_vs_internet Last edited by HatCat; 4th January 2018 at 03:28 PM. |