4 ms·
Yes it's probably only really useful for parallel code, but it's always nice to make constant things const.
by excuse-me 15y ago
Yes it's probably only really useful for parallel code, but it's always nice to make constant things const.
- gte910h 15y agoWhy use "const int" there instead of #define? Far fewer issues with linkage and use in multiple files with #define.
- oldcigarette 15y agoNo. If it's const it is static be default. This is the kind of shit that makes the windows api the royal pain in the ass it is.
- gte910h 15y ago>If it's const it is static be default. If it's const at the file scope it's notably NOT static in the 'visible in the file scope only' sense of the word. Try it, declare a const int at file scope in a C file and use it in a different C file with a extern prototype.
- excuse-me 15y agoBecause you can do this at runtime. I might have a different value everytime I call the function but this means that inside the fucntion the compiler knows the value can't change
- gte910h 15y agoWhy ever use const at a file scope level. That's what I mean. #defines work SO much better there. Especially if being used outside the file.