4 ms·
Honestly, it's just about doing what is easier at the time. Re-compiling an application in debug can be a pain sometimes, or getting back to a specific state wi
by bArray 2y ago
Honestly, it's just about doing what is easier at the time. Re-compiling an application in debug can be a pain sometimes, or getting back to a specific state within the application to inspect what is going on. Some have mentioned about hardware (which marches on with or without software running), but similarly part of a system where you only really control one sub-system/interface.
My print statements normally come when "I have no idea why this is breaking", and I start sanity checking the basics to make sure that things I previously thought were true, remain so.
Just recently I was doing something in C after a long time, and had something like this (simplified):
#include <stdio.h>
int main(){
int a = 0; // Input from elsewhere
switch(a){
case 0 :
printf("0\n");
break;
defult :
printf("?\n");
break;
}
return 0;
}
It was late at night, it compiled, so I knew it wasn't a grammar issue. But after testing with printf()'s I realised that the default case was never being hit and performing the core action. It turns out 'defult' highlights in my editor and compiles fine in GCC. Turns out that any word in that location compiles fine in GCC. Nasty!
- amszmidt 2y agoWell, yes .. it is a label, and a label can be put almost anywhere. This is normal, expected C behavior and any standard conformant compiler would behave the same, not just GCC.
- bArray 2y agoI think it should at least warn that it is not used by default, or recognise that unused labels within switch statements are likely to be a mistake. Anyway, the point was, my tired eyes did not easily grep the spelling mistake, hence the print statements.