TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: John Poltorak
from: Paul Person
date: 1996-01-28 05:24:20
subject: Re: C errors

-=> Quoting John Poltorak to All <=-

 JP> Every few months I try and make some progress with C and get stuck...

 JP> After installing MetaWare C++ from DevCon 9, I've been attempting to
 JP> build some of the sample programs provided. I have the makefiles and
 JP> all the required code (from the v2.1 Toolkit), but still I get errors
 JP> such as:- 



 JP> Can someone explain these errors and how I should correct them?

 JP> Some of the errors above just seem like sloppy coding, which shouldn't
 JP> make it into production code suitable for teaching... 

First, most of them look like warnings rather than errors. Does "w" mean 
warning and "E" error by any chance? 

Second, one of the "warnings" is informational ("How
referenced files were 
included"), which could be helpful in resolving some types of problems. 

Third, most of the warnings involve converting "UCHAR *" to
"char *" (or 
vice-versa, assuming "PUCHAR" is the same as "UCHAR
*"). Assuming UCHAR has 
a reasonably obvious definition ("unsigned char"), this should not be a 
problem unless you are planning to do arithmetic on the data. Since they 
appear to be associated with string functions, they are probably not 
anything to worry about. An explicit cast should suppress them. 

Fourth, the warnings about "=" instead of "==" are
there because a common 
error in conditions is to use "=" when "==" is meant:
if(A=B) versus 
if(A==B). The first assigns the value of B to A and uses the value of B for 
the test, the second compares the values of A and B and returns a value 
based on whether they are the same or not. *These* are the warnings you 
want to look at to try to determine whether an assignment was intended or 
not. (An assignment is often intended in forms like if(A=f()), where 
function f() returns a value which is to be tested for success).

I should mention that, in my limited experience, the above situations 
normally produce warnings rather than errors.

Finally, it appears that the only actual error was an attempt to convert 
"UCHAR *" to "PCSZ". Consulting the OS2DEF.H that came
with Watcom C/C++ 
10.5 shows that, for C++, PCSZ is "const char *" but that, for C, it is 
"unsigned char *". The same file shows that UCHAR is indeed "unsigned 
char", so all I can suggest is that casting to const is a problem. I would 
try an explicit cast and, if that doesn't work, change the type of the 
parameter (that is, of whatever is being passed to the function) to "const 
char *" (assuming you are using C++). (Watcom objected to the same sort of 
problem in a C library, not using OS/2, but as a warning rather than an 
error, a warning that casting would not suppress).
`
--- Blue Wave/Max v2.12 [NR]
* Origin: OS/2 Northwest, Bellevue, WA 206-957-4513 206-562-7212 (1:343/179)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 343/179 100 1 138/103 3615/50 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.