public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/32449]  New: declaring “strcmp()” as an extern function with inclusion of “string.h” is causing compilation error
@ 2007-06-21  7:58 suma dot sharma at kpitcummins dot com
  2007-06-21  8:45 ` [Bug c/32449] " schwab at suse dot de
  0 siblings, 1 reply; 2+ messages in thread
From: suma dot sharma at kpitcummins dot com @ 2007-06-21  7:58 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2752 bytes --]

Hi,

I have successfully built SH4-Linux toolchain based on
(binutils-2.17, gcc-4.2-20061205, glibc-2.5) for Renesas SH target.

I am facing problems while compiling the following testcase-

 ------------------------------------------------------------------
TESTCASE
#include<string.h>
#include<stdio.h>

extern int strcmp(const char *,const char *);

int main()
{
        char s1[3];
        char s2[3];
        strcpy(s1,"12");
        strcpy(s2,"2");
        printf("\n\t %d",strcmp(s1,s2));
        return 0;
}

-------------------------------------------------------------------------       

PROBLEM
The above testcase gets compiled with '-O0' optimization successfully----
…/sh4-linux-gcc testcase.c –o a.out –O0

but on compilation with '-O2' optimization option------ 
…/sh4-linux-gcc testcase.c –o a.out –O2

it gives the following
error:-

testcase.c:4: error: expected identifier or ‘(‘ before ‘__extension__’
testcase.c:4: error: expected identifier or ‘(‘ before ‘)’ token

OBSERVATIONS
1. In the above testcase, declaring “strcmp()” as an extern function with
inclusion of “string.h” is causing the above mentioned compilation error. But
on the other hand, if either of the two scenarios is used i.e. either
“string.h” is included or “strcmp()” is declared as an extern function only,
then it compiles successfully with –O2 option. 

2. This problem has been observed with
                   sh-linux toolchain (gcc-4.2) 
                   i686-pc-linux toolchain (gcc-4.1.1, Fedora Core 6)
                   i686-pc-linux toolchain (gcc-4.2.0)

Any help on this will be appreciated.

Regards,
Suma Sharma
KPIT Cummins Infosystems Ltd,
Pune (INDIA)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
Free download of GNU based SH-Linux toolchains for Renesas' SH Series.          
The following site also offers free technical support to its users.             
Visit http://www.kpitgnutools.com for details.                                
Latest versions of KPIT GNU SH-Linux tools were released on April 5, 2007.      
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


-- 
           Summary: declaring “strcmp()” as an extern function with
                    inclusion of “string.h” is causing compilation error
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: suma dot sharma at kpitcummins dot com
 GCC build triplet: i686-pc-linux
  GCC host triplet: sh4-unknown-linux
GCC target triplet: sh4-unknown-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32449


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/32449] declaring “strcmp()” as an extern function with inclusion of “string.h” is causing compilation error
  2007-06-21  7:58 [Bug c/32449] New: declaring “strcmp()” as an extern function with inclusion of “string.h” is causing compilation error suma dot sharma at kpitcummins dot com
@ 2007-06-21  8:45 ` schwab at suse dot de
  0 siblings, 0 replies; 2+ messages in thread
From: schwab at suse dot de @ 2007-06-21  8:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from schwab at suse dot de  2007-06-21 08:45 -------
<string.h> may define strcmp as a macro.  This has nothing to do with the
compiler.


-- 

schwab at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32449


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-21  8:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-21  7:58 [Bug c/32449] New: declaring “strcmp()” as an extern function with inclusion of “string.h” is causing compilation error suma dot sharma at kpitcummins dot com
2007-06-21  8:45 ` [Bug c/32449] " schwab at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).