How to suppress minor C compiler warnings


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to suppress minor C compiler warnings
# 1  
Old 10-02-2008
MySQL How to suppress minor C compiler warnings

Hi, I develop code using a few different solaris platforms. I've recently moved to SunOS 5.10 using the following c compiler.

Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25

On this box and these versions I get hundreds of warnings that do not appear of the earlier solaris/c versions.

Is there a compiler setting or cflag that will surpress these minor warnings?Smilie

Code:
CC -c -g -mt -D_SOLARIS -DTHREADSAFE  -DVERSION="\"1.1\"" -I. -I/export/home/dev/api -I/export/home/dev/v3.8/inc -I/export/home/dev/v3.10/inc test.cpp
"test.cpp", line 68: Warning: Last line in file "test_utils.h" is not terminated with a newline.
"test.cpp", line 199: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 305: Warning: String literal converted to char* in formal argument sStr2 in call to strbegin(char*const, char*const).
"test.cpp", line 311: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 313: Warning: String literal converted to char* in formal argument sStr2 in call to strbegin(char*const, char*const).
"test.cpp", line 318: Warning: String literal converted to char* in formal argument sStr2 in call to strbegin(char*const, char*const).
"test.cpp", line 323: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 348: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 380: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 388: Warning: String literal converted to char* in formal argument sStr2 in call to strbegin(char*const, char*const).
"test.cpp", line 389: Warning: String literal converted to char* in formal argument sStr2 in call to strbegin(char*const, char*const).
"test.cpp", line 425: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 529: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 533: Warning: String literal converted to char* in formal argument sStr2 in call to strbegin(char*const, char*const).
"test.cpp", line 538: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 547: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 548: Warning: String literal converted to char* in formal argument sStr2 in call to strbegin(char*const, char*const).
"test.cpp", line 553: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 560: Warning: String literal converted to char* in assignment.
"test.cpp", line 563: Warning: String literal converted to char* in assignment.
"test.cpp", line 566: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 572: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 585: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 599: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 619: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 628: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 631: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 640: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 649: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).
"test.cpp", line 716: Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*).

# 2  
Old 10-02-2008
Maybe, check the man page / documentation of your compiler? Usually CC is often (always?) a link to your compiler. When looking for the man page, you might have to use it's real name ie. where the link points at.
# 3  
Old 10-05-2008
FWIW - there really is no such thing as a compile with warnings. If this code has any importance at all it has to compile cleanly.

Quote:
According to C99 [ISO/IEC 9899:1999] Section 5.1.1.3:

A conforming implementation shall produce at least one diagnostic message (identified in an implementation-defined manner) if a preprocessing translation unit or translation unit contains a violation of any syntax rule or constraint, even if the behavior is also explicitly specified as undefined or implementation-defined. Diagnostic messages need not be produced in other circumstances.
In other words you are asking the compiler to do something that does not exist or varies from box to box - and you are porting code.

You cannot assume the code will ever work as expected.
# 4  
Old 10-05-2008
Regarding "Warning: String literal converted to char* in formal argument msg in call to debug(char*, char*)"

This warning message probably means you are passing a string literal (which is of type (const char *) i.e. not modifiable) to debug(). Changing the prototype for debug() should eliminate a considerable number of warnings.
# 5  
Old 10-06-2008
I understand that these warnings are appearing as a result of errors in the code, but what I can't understand is why these warnings appear only on this version of solaris with this version of the c compiler. There are far too many files involved to go through each and correct these. I want a setting to suppress these minor warnings.

If I compile the exact same sourcecode on SunOS 5.8 using Sun WorkShop 6 update 1 C++ 5.2, or on Windows XP using Microsoft 32-bit C/C++ Standard Compiler Version 12.00.8168, I don't get any warnings.

Can you explain why this is?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Minor changes to script

isNumeric() { numericExpression='^+$' if ! ] then echo 1; else echo 0; fi } getColumnData() { echo `echo $1|cut -d "," -f1,2 --output-delimiter " "` } containsSegment() { if ] || ] || ] ... (2 Replies)
Discussion started by: ramyags
2 Replies

2. Shell Programming and Scripting

Minor Calculation Error

Hello everyone!! I got a slight problem doing some calculation from the text file. I able to get the specific data by cutting it using grep and cut. The amount can be calculated but the problem I faced now is even the field which I didnt cut is been calculated too. This is what I meant. The... (2 Replies)
Discussion started by: aLHaNz
2 Replies

3. UNIX for Dummies Questions & Answers

Changing colors for compiler errors/warnings

Hi, I am using GNU unix. And running a bash shell. Can anyone please tell me what is the command for changing the color of the compiler error/warning messages on the console. I think it is in .bashrc and do not know how. Thanks Pink (1 Reply)
Discussion started by: pink01
1 Replies

4. UNIX for Advanced & Expert Users

Changing colors for compiler errors/warnings

Hi, I am using GNU unix. And running a bash shell. Can anyone please tell me what is the command for changing the color of the compiler error/warning messages on the console. I think it is in .bashrc and do not know how. Thanks Pink (0 Replies)
Discussion started by: pink01
0 Replies

5. Solaris

Not getting warnings!!

I have tried to compile the code on solaris which is bash-3.00$ uname -a SunOS zen 5.7 Generic_106541-37 sun4u sparc SUNW,Ultra-80 bash-3.00$ CC -V CC: WorkShop Compilers 5.0 98/12/15 C++ 5.0 when I compile just a simple program, int main() { long kk = 200; int jj = kk; return... (0 Replies)
Discussion started by: amit_27
0 Replies

6. Programming

How Can a Machine Reads a Compiler Since A Compiler is Written in Text! Not Binaries?

To make a programming language you need a compiler, so what was the first programming language and how was is created if you need the compiler first? The compiler itself is considered as a high language comparing to the machine! since the compiler is not created in 1's and 0's... Eventhough i... (12 Replies)
Discussion started by: f.ben.isaac
12 Replies

7. Shell Programming and Scripting

Suppress awk warnings

Hello everyone, Sorry if this is a bit of an RTM thing, but I can't find any flags for suppressing warnings with awk and Googling (this site too) didn't yield much useful. Does anyone know how to suppress warnings? The warning I'm specifically trying to remove is one warning me that I'm... (1 Reply)
Discussion started by: kdelok
1 Replies

8. Solaris

CC 5.5 compiler flag to issue 64bit porting warnings on sparc-solaris

Hi, We are porting our application from 32bit to 64bit. We tried -xarch=v9, -xarc=v9a and -xport64=full options so that compiler to issue 64bit porting warnings. But we are not getting any porting warninings WE are using CC 5.5 compiler on sparc-solaris m/c. Please tell us some powerful... (0 Replies)
Discussion started by: shobhah
0 Replies
Login or Register to Ask a Question