C Language Help

John Anthony Kazos Jr. jkazos@vt.edu
Thu May 22 21:44:00 GMT 2003


I don't know if this is appropriate here or not, but since I figure my 
solution (if there is a solution) is some sort of compiler option, I 
thought I'd ask.

1) Let's say I have typedef'd "Abcde" and "Fghij" to "unsigned int". How do 
I get the following code to produce a warning, if not an error, if I do not 
explicitly cast?

Abcde var1;
Fghij var2;

var1 = 5;
var2 = var1;
var1 = var2;

2) How do I get the following code to produce a warning, if not an error, 
if I do not explicitly cast?

int var1;
signed int var2;
unsigned int var3;
var1 = 5;
var2 = var1;
var3 = var1;
var1 = var2;
var1 = var3;

(I guess I can summarize by saying, how do I get the compiler to produce a 
warning, if not an error, for any kind of implicit casting? Basically, 
disabling implicit casting entirely and forcing everything, no matter how 
trivial, to be explicitly cast?

If this is even possible, do you know any parts of ISO/IEC 9899:1999 
Cor1:2001 that may or will shatter, and what I can do about it? I am hoping 
that since I am going to use nothing but the standard language includes and 
some standard Un*x includes, I won't have to do anything but explicitly 
cast some parameters aimed inside or outside of my program...)



More information about the Gcc-help mailing list