Thread View: csu.cs.200
4 messages
4 total messages
Started by spasm
Wed, 30 Sep 1998 00:00
Help with aCC compiling errors
Author: spasm
Date: Wed, 30 Sep 1998 00:00
Date: Wed, 30 Sep 1998 00:00
37 lines
1804 bytes
1804 bytes
Using the old CC command to compile my assignment #3 program, I recieved
no errors and achieved the desired output. Using the new aCC command to
compile my program, I get the following errors:
1. Error (future) 355: "Main3.C", line 46 # Function 'main' must return
type 'int'.
void main()
^^^^
2. Error 409: "Main3.C", line 128 # Cannot convert a non-lvalue to a
pointer.
if(strcmp((LIST_Get(list,j)).name,(LIST_Get(list,index)).name) >
0) ^^^^^^^^^^^^^^^^^^^^^^
3. Error 409: "Main3.C", line 128 # Cannot convert a non-lvalue to a
pointer.
if(strcmp((LIST_Get(list,j)).name,(LIST_Get(list,index)).name) >
0)
^^^^^^^^^^^^^^^^^^^^^^^^^^
4. Warning: 1 future errors were detected and ignored. Add a '+p'
option to
detect and fix them before they become fatal errors in a future release.
Behavio
r of this ill-formed program is not guaranteed to match that of a
well-formed pr
ogram
After adding the '+p' option, error 355 is gone. The file Main3.C is
supposed to compile, so I'm guessing that there is something in my SLL.h
and ArrD.h files that is causing the problem. I get the same errors
including either SLL.h or ArrD.h in Main3.C. Any ideas as to what could
be causing this.
Thanx,
Chris Carlson
Re: Help with aCC compiling errors
Author: Adam Carheden
Date: Thu, 01 Oct 1998 00:00
Date: Thu, 01 Oct 1998 00:00
38 lines
1841 bytes
1841 bytes
spasm wrote: > 1. Error (future) 355: "Main3.C", line 46 # Function 'main' must return > type 'int'. > void main() > ^^^^ I think Chuck spoke about this in class. The new standard is for main to return an int to tell the OS that it has executed successfully. Just change void main() to int main() and add return 1; to the end of main. (I think 1 means okay, 0 means there was an error.) > 2. Error 409: "Main3.C", line 128 # Cannot convert a non-lvalue to a > pointer. > > if(strcmp((LIST_Get(list,j)).name,(LIST_Get(list,index)).name) > > 0) ^^^^^^^^^^^^^^^^^^^^^^ > > 3. Error 409: "Main3.C", line 128 # Cannot convert a non-lvalue to a > pointer. > > if(strcmp((LIST_Get(list,j)).name,(LIST_Get(list,index)).name) > > 0) > ^^^^^^^^^^^^^^^^^^^^^^^^^^ I'm not sure that this makes sense for the error, but LIST_Get should return type LISTdata; make sure it's LISTdata and not a pointer to LISTdata. I would think this would have given you errors under CC too though. Try compiling with g++ too. I find that sometimes different compilers will give more understandable errors. Good luck. -- Adam carheden@holly.colostate.edu http://holly.ColoState.edu/~carheden
Re: Help with aCC compiling errors
Author: root
Date: Fri, 02 Oct 1998 00:00
Date: Fri, 02 Oct 1998 00:00
58 lines
2552 bytes
2552 bytes
spasm <spasm@holly.colostate.edu> wrote:
: Using the old CC command to compile my assignment #3 program, I recieved
: no errors and achieved the desired output. Using the new aCC command to
: compile my program, I get the following errors:
: 1. Error (future) 355: "Main3.C", line 46 # Function 'main' must return
: type 'int'.
: void main()
: ^^^^
aCC is a stricter compiler .. so U need to return a value before exiting
So use int main() instead of void main()
^^^ ^^^^
and before u exit from the main, use
return(1) ---> for abnormal termination
return(0) ---> for normal termination
: 2. Error 409: "Main3.C", line 128 # Cannot convert a non-lvalue to a
: pointer.
: if(strcmp((LIST_Get(list,j)).name,(LIST_Get(list,index)).name) >
: 0) ^^^^^^^^^^^^^^^^^^^^^^
Yep .. this doesn't work with aCC ..
U need to assign LIST_Get(list,j).name to a termorary character string
and then compare the temp string.
It works with aCC tho.
: 3. Error 409: "Main3.C", line 128 # Cannot convert a non-lvalue to a
: pointer.
: if(strcmp((LIST_Get(list,j)).name,(LIST_Get(list,index)).name) >
: 0)
: ^^^^^^^^^^^^^^^^^^^^^^^^^^
Same as above
: 4. Warning: 1 future errors were detected and ignored. Add a '+p'
: option to
: detect and fix them before they become fatal errors in a future release.
: Behavio
: r of this ill-formed program is not guaranteed to match that of a
: well-formed pr
: ogram
: After adding the '+p' option, error 355 is gone. The file Main3.C is
: supposed to compile, so I'm guessing that there is something in my SLL.h
: and ArrD.h files that is causing the problem. I get the same errors
: including either SLL.h or ArrD.h in Main3.C. Any ideas as to what could
: be causing this.
: Thanx,
: Chris Carlson
--
VISHWANATH PARAKALA
__________________________________________________________________________
Home Page: http://www.cs.colostate.edu/~vishu
finger : vishu@schubert.cs.colostate.edu
Re: Help with aCC compiling errors
Author: ken shrum
Date: Tue, 06 Oct 1998 00:00
Date: Tue, 06 Oct 1998 00:00
54 lines
2514 bytes
2514 bytes
spasm (spasm@holly.colostate.edu) wrote:
: Using the old CC command to compile my assignment #3 program, I recieved
: no errors and achieved the desired output. Using the new aCC command to
: compile my program, I get the following errors:
On an HP machine, CC should only be used for backward compatibility
for legacy applications. This is not what you folks are doing. I
encourage you to only use aCC, unless you have specific instructions
otherwise.
aCC more closely tracks the ISO standard for C++, although it is not
yet conformant.
: 1. Error (future) 355: "Main3.C", line 46 # Function 'main' must return
: type 'int'.
: void main()
: ^^^^
In Standard C++, there are two legal signatures for main:
int main()
int main(int argc, char** argv)
However, your main function does not have to actually return a value
(for backward compatibility with older C++ apps). Falling out of main
without a return is the same as returning zero.
: 2. Error 409: "Main3.C", line 128 # Cannot convert a non-lvalue to a
: pointer.
: if(strcmp((LIST_Get(list,j)).name,(LIST_Get(list,index)).name) >
: 0) ^^^^^^^^^^^^^^^^^^^^^^
: 3. Error 409: "Main3.C", line 128 # Cannot convert a non-lvalue to a
: pointer.
: if(strcmp((LIST_Get(list,j)).name,(LIST_Get(list,index)).name) >
: 0)
: ^^^^^^^^^^^^^^^^^^^^^^^^^^
These are the same error, dressed differently. I'd have to see the
spec for LIST_Get, but it appears to be returning a struct/class type
by value, where the name field is of type char*. (This is just my
guess from the code shown)
An un-named temporary, which includes things returned by value from
functions, is not an lvalue. An lvalue is something that can appear
on the left hand side of an assignment operator, a "left value."
Variables are lvalues, for example. Taking the address of a temporary
is bad, since the temporary won't outlive the expression.
Again, this is just my best guess. Without more context, it's hard
to tell.
Ken Shrum
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads