Anteru's blog
  • Consulting
  • Research
    • Assisted environment probe placement
    • Assisted texture assignment
    • Edge-Friend: Fast and Deterministic Catmull-Clark Subdivision Surfaces
    • Error Metrics for Smart Image Refinement
    • High-Quality Shadows for Streaming Terrain Rendering
    • Hybrid Sample-based Surface Rendering
    • Interactive rendering of Giga-Particle Fluid Simulations
    • Quantitative Analysis of Voxel Raytracing Acceleration Structures
    • Real-time Hybrid Hair Rendering
    • Real-Time Procedural Generation with GPU Work Graphs
    • Scalable rendering for very large meshes
    • Spatiotemporal Variance-Guided Filtering for Motion Blur
    • Subpixel Reconstruction Antialiasing
    • Tiled light trees
    • Towards Practical Meshlet Compression
  • About
  • Archive

Working at warning level 4

January 10, 2007
  • Programming
approximately 2 minutes to read

On Linux, I develop usually with -pedantic -ansi -strict -Werror -Wall which makes basically any warning an error and turns on virtually all available warnings (unused variables, anyone?). Most of the time the Linux programs were rather small though. Yesterday, I tried the same (i.e. warning level 4) on Windows. Read on for results.

Warning level 4 - the cutting edge

Warning level 4 is above the default level, and it is there for a good reason. You will get a lot of warnings, no matter how good your code is, the good thing is that you usually wind up with 3-4 bogus warnings you can disable and if your code is standards-conforming and well written, that should have been it.

Warnings I disable by default

  • C4251 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'. This appears for things like boost::noncopyable. As long as your know that your clients will have the interface in question, you can safely ignore that.
  • C4275 non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'. Basically the same as above.
  • C4190 'identifier1' has C-linkage specified, but returns UDT 'identifier2' which is incompatible with C. Happens as you you have an external "C" function which returns a C++ class. As long as you know that your clients will use C++, this can be ignored.

Disabled warnings from level 4

  • C4127 conditional expression is constant. Actually I didn’t want to disable it, but unfortunately it crops up all the time in boost::lexical_cast. It’s not that bad to disable it because mistakes like a = b instead of a == b will be caught by a different warning.
  • C4512 assignment operator could not be generated. Well, that’s bad luck, but you’ll notice it anyway when you try to assign it, if you don’t try, then you probably didn’t want it.
  • C4510 default constructor could not be generated. Crops up when you define a struct with a const char* member. Yeah, it cannot be default initialized, but as usual, you’ll get an error if you try to.
  • C4610 struct 'indentifier' can never be instantiated - user defined constructor required. Same as above.

With this warnings disabled I’ve been able to recompile niven without warnings, and I found a bug! In one function, I haven’t used a formal parameter which was now highlighted as a warning and was indeed a real bug. So, turning you warning level up to 4 can be really helpful!

Previous post
Next post

Recent posts

  • Data formats: Why CSV and JSON aren't the best
    Posted on 2024-12-29
  • Replacing cron with systemd-timers
    Posted on 2024-04-21
  • Open Source Maintenance
    Posted on 2024-04-02
  • Angular, Caddy, Gunicorn and Django
    Posted on 2023-10-21
  • Effective meetings
    Posted on 2022-09-12
  • Older posts

Find me on the web

  • GitHub
  • GPU database
  • Projects

Follow me

Anteru NIV_Anteru
Contents © 2005-2025
Anteru
Imprint/Impressum
Privacy policy/Datenschutz
Made with Liara
Last updated February 20, 2019