Skip to main content

New answers tagged

3 votes

How to prevent 'global variables' in a big project?

In the new bright world of C++ Core Guidelines (endorsed by no less than Bjarne Himself and current WG21 convener Herb Sutter) - there is Clang-tidy, and its avoid-non-const-global-variables option: ...
No-Bugs Hare's user avatar
1 vote

Should I assume data passed to my function is accurate?

As designed, you cannot check in C that the string is properly initialised. The solution is to change things so the function called is responsible for everything. Don’t pass in a pointer that might be ...
gnasher729's user avatar
  • 46.7k
0 votes

C/C++: Which conversion warnings make sense in practice?

You get the int-to-float warning because int > 2^24 are usually converted with an error. My rule is that you should use double unless you can give a good reason to use float. So what is your reason ...
gnasher729's user avatar
  • 46.7k
1 vote

C/C++: Which conversion warnings make sense in practice?

Here's what decades of experience have taught me. Turn on all the conversion warnings and tell the compiler to treat all warnings as errors. The conversions that must happen should be made explicit ...
Adrian McCarthy's user avatar

Top 50 recent answers are included