Code:
extern unsigned long int get_absolutevalue(const long int number)
{
if(number < 0)
return (~number + 1);
return (number)
}
Code:
const unsigned int length = strlen(line);
Code:
error: conversion to ‘long unsigned int’ from ‘long int’ may change the sign of the result [-Werror=sign-conversion]
error: conversion to ‘unsigned int’ from ‘size_t {aka long unsigned int}’ may alter its value [-Werror=conversion]
I have similar idiotic complaints all over my code.
I usually declare every variable that can't be negative, as unsigned, so there's plenty of errors like these everywhere.I started explicitly casting one by one to shut up the compiler when I wondered if this was really necessary.
Since I'd like to be a good programmer some day and write good, standard compliant and error free code, I have to ask if there's any value in doing all this unnecessary casting or if I should get rid of the stupid flag?
Thank you.