This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes C / C++ and the fly likes Explanation  to the strange compile time error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "Explanation  to the strange compile time error" Watch "Explanation  to the strange compile time error" New topic
Author

Explanation to the strange compile time error

Rachit Kumar Saxena
Ranch Hand

Joined: Dec 24, 2011
Posts: 50
Just as I compiled:

#include<stdio.h>

main()
{
print("hello\cworld");
}

I got this error/output:

warning:unknown escape sequence '\c'

C:\Uers\Abc\Appdata\Local\Temp/ccQLcaaa.o(.txt+ox32):abc.c:undefined reference to 'print'

ld returned 1 exit status.Can anyone of you deduce this error and tell me,in some words,what the compiler wants to say(especially "undefined reference" one)
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
The first one is pretty obvious. The character '\c' is not recognised as a valid escape sequence. If you actually wanted to include the two characters '\' and 'c' in your string, then you need to escape the '\'. If you intended the '\c' to be an escape sequence, what did you think it meant ?

Don't know on the second one (It's been a while since I did any C programming), but I would guess it might mean it doesn't have a definition for the print method.
Rachit Kumar Saxena
Ranch Hand

Joined: Dec 24, 2011
Posts: 50
Sir,Thanks for your reply,but the first one the is just a warning,and wanted to know the meaning of the error,that is the second one.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41084
    
  29
It is pretty obvious; the error message says it all.
 
Consider Paul's rocket mass heater.
 
subject: Explanation to the strange compile time error