New to C++ equivalent Visual Express error detection in g++/gdb ?
MS Visual Express C++ catches goofs such as:
int CLASSA = 80.00; //Cost per A Class ticket. warning: initalizing: conversion from double to int, possible loss of data I am looking to have the same thing using g++ but have not seen it in man. |
Couldn't test it at the moment, but here's some compiler flags you can try: -W -Wall -Wextra -pedantic
|
You need -Wconversion, although it doesn't warn for 80.00 because there is no possible loss of precision there. It does for warn for 80.01.
|
I had been trying -Werror -Wall -Wextra
Thank you. -Wconversion is what I was looking for. Just too bad it waits until 80.01 instead of 80.00. I will have to get better at proofreading. |
Quote:
Code:
sergei@amdam2:~/junk/c++_work/strict_types> cat -n main.cxx I.e. my goal is to be able to avoid exactly errors of such kind. |
All times are GMT -5. The time now is 08:10 AM. |