473,396 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

getting copilation error with gcc 3.4.2

Hi,
I am getting compilation error "error: parse error before
"__extension__"" for following line of 'C' code:

extern char *strchr(const char *s, int c);
("I had to put this line for some other reasons")

I am using gcc 3.4.2. And, this error is coming only with '-O' option.
With '-g', it is compiling.

Can somebody please help me out.

--Thanks and Regards,
saurabh

Nov 14 '05 #1
4 1226
Hi,
Sorry, I forgot to mention that I am using following Linux machine:
uname -a Linux machinename 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001 i686 unknown
cat /etc/redhat-release

Red Hat Linux release 7.2 (Enigma)

--Thanks,
saurabh

Nov 14 '05 #2


Ashay wrote:
Hi,
I am getting compilation error "error: parse error before
"__extension__"" for following line of 'C' code:

extern char *strchr(const char *s, int c);
("I had to put this line for some other reasons")

I am using gcc 3.4.2. And, this error is coming only with '-O' option.
With '-g', it is compiling.

Can somebody please help me out.


You have probably #include'd <string.h> in the source,
either directly or indirectly. Once you have done so, you
must not attempt to re-declare the names that <string.h> has
already declared for you. Three possible fixes:

- (poor) Write `extern char *(strchr)( ...etc... );'

- (better) Delete the offending declaration altogether.

- (best) Delete the declaration *and* insert an explicit
#include <string.h> if it's not already there (some
other #include file may pull in <string.h> on your
behalf, but that might change someday -- and if you
#include it explicitly, you'll guard against the
breakage that "someday" might otherwise cause).

--
Er*********@sun.com

Nov 14 '05 #3
"Ashay" <sa*************@yahoo.com> writes:
I am getting compilation error "error: parse error before
"__extension__"" for following line of 'C' code:

extern char *strchr(const char *s, int c);
("I had to put this line for some other reasons")

I am using gcc 3.4.2. And, this error is coming only with '-O' option.
With '-g', it is compiling.

Can somebody please help me out.


I presume the ("I had to put this line for some other reasons") is
your comments, and doesn't appear in the source.

Probably strchr is defined as a function-like macro whose definition
uses some non-standard extension called "__extension__".

The way to get the declaration for strchr() is "#include <string.h>".
Why do you need to declare it yourself?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #4
Thanks a lot!!
I saw the preprocessed file and could see the issue. But, Is this
function a macro only in optimized mode and not in '-g' build. Because,
I saw different preprocessed outputs in both the cases.
Actually, somebody in group had put this extern declaration, because he
was not getting incorrect return type("int") for this function, even
after including <string.h>. But, i saw there are many other files
included after this, so some other header file must be redefining
'strchr' which was evetually causing crashes on 64 bit machines,
because of the size diff in 'char*' and 'int'.
But, I think I will be able to solve this issue now.

--Thanks and Best Regards,
saurabh

Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
4
by: Pat | last post by:
In my Web.config i have :- <customErrors mode="On" defaultRedirect="genericerror.htm"> <error statusCode="404" redirect="pagenotfound.aspx"/> </customErrors to get page not found error but...
32
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is...
2
by: MSK | last post by:
Hi, Continued to my earlier post regaring "Breakpoints are not getting hit" , I have comeup with more input this time.. Kindly give me some idea. I am a newbie to .NET, recently I installed...
0
by: MSK | last post by:
Dear all, Continued to my earlier mail regarding "Breaking points are not getting hit in ASP.NET " , I got some idea from net. Can anyone give me more idea on this? Just to remind the issue:...
2
by: Manikandan | last post by:
Hi, I have a program written in .Net Framework 1.1 using Visual studio enterprise edition 2003. I tried compiling the same program in visual c# express edition 2005. I'm getting following...
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
4
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.