public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* cc and gcc compilers
@ 2003-10-17  6:44 Nguyen, KhaiDinh
  2003-10-20 19:01 ` Per Bothner
  0 siblings, 1 reply; 3+ messages in thread
From: Nguyen, KhaiDinh @ 2003-10-17  6:44 UTC (permalink / raw)
  To: 'gcc-bugs@gcc.gnu.org', 'bug-gcc@gnu.org',
	'gcc@gcc.gnu.org'

****************************************************************
                            IMPORTANT

 The information transmitted is for the use of the intended recipient only and may contain confidential and/or legally privileged material. Any review, re-transmission, disclosure dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may result in severe penalties.  If you have received this e-mail in error please notify the Privacy Hotline of the Australian Taxation Office, telephone 13 28 69 and delete all copies of this transmission together with any attachments. 
****************************************************************

Hi,
My name is KhaiDinh from Australia (down-under country).

We are migating many C programs from (old) NCR Unix system to AIX.

These C programs are non-ansi standard and compiled by using NCR unix cc
compiler.

In the new system AIX, we have problems of compiling these C programs when
using gcc. It displays error messages because these C programs are
"NON-ANSI"; eg. variable declared after statements/variable assignments.

My question is that is there any way to compile our NON-ANSI C programs by
using gcc, eg any option to disable -ansi flag....?
Is there any other C compilers can be used to compile our NON-ANSI C
programs?
We don't have time & resources to modify 500 C programs to make them conform
to ANSI standard.

I'd be apreciated if you can help us. I'm waiting for your advise and help.

Many thanks.

Regards,
KhaiDinh Nguyen


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

* Re: cc and gcc compilers
  2003-10-17  6:44 cc and gcc compilers Nguyen, KhaiDinh
@ 2003-10-20 19:01 ` Per Bothner
  0 siblings, 0 replies; 3+ messages in thread
From: Per Bothner @ 2003-10-20 19:01 UTC (permalink / raw)
  To: Nguyen, KhaiDinh; +Cc: 'bug-gcc@gnu.org', 'gcc@gcc.gnu.org'

Nguyen, KhaiDinh wrote:

> ****************************************************************
>                             IMPORTANT
> 
>  The information transmitted is for the use of the intended recipient only and may contain confidential and/or legally privileged material. Any review, re-transmission, disclosure dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may result in severe penalties.  If you have received this e-mail in error please notify the Privacy Hotline of the Australian Taxation Office, telephone 13 28 69 and delete all copies of this transmission together with any attachments. 
> ****************************************************************

Please do not post messages that "may be confidential" to public lists.
Please do not post (il)legal boiler-plate to the GNU mailing lists.
This is rude, possibly illegal, and suggests your company has
clueless lawyers and/or management.  (Hint: Big computer-savvy
companie don't do this, because they know it is pointless and
offensive.)

[I think you're confused about the -ansi flag.  Gcc, at least
version 3.3.1, allows declarations to follow statements, with
or without the -ansi flag.]
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/



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

* RE: cc and gcc compilers
@ 2003-10-22 22:49 Nguyen, KhaiDinh
  0 siblings, 0 replies; 3+ messages in thread
From: Nguyen, KhaiDinh @ 2003-10-22 22:49 UTC (permalink / raw)
  To: 'Colin Douglas Howell',
	Jim Wilson, 'zgene@hotmail.com', 'Dan.Pop@ifh.de',
	gcc, 'bug-gcc@gnu.org', 'gcc@gcc.gnu.org',
	'Per Bothner'

****************************************************************
                            IMPORTANT

 The information transmitted is for the use of the intended recipient only and may contain confidential and/or legally privileged material. Any review, re-transmission, disclosure dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may result in severe penalties.  If you have received this e-mail in error please notify the Privacy Hotline of the Australian Taxation Office, telephone 13 28 69 and delete all copies of this transmission together with any attachments. 
****************************************************************

Hi,
Many thanks for the replies. My apology for the Disclaimer. Please ignore
it. The disclaimer is generated atomatically by my organisation system.

Colin's reply described exactly what happens to our system. Also when
searching on internet I found that Zgene got the same problem and Dan
suggested that with a new gcc version (3.x.x) may accept mixed declarations
and code (attached). We hope that it's the case.

Our current version of gcc is 2.9-aix51-020209. Is it old? Is there a newer
version of gcc for AIX which can accept mixed declarations and code?

Conversion our 500 c programs (moving declaration to top of function) is our
last option if we cannot find any options in gcc which accept mixed
declarations and code.

If we have no other choices and we have to convert them. Any automate
conversion softwares we can use to convert them (instead of manually
converting them - we might introduce more problems by mistakes when manually
convert them)?

Please help. Many thanks for your time.

Regards,
KhaiDinh Nguyen
----------------------------------------
Attached:
----------------------------------------

From: Dan Pop (Dan.Pop@ifh.de)
Subject: Re: What a stupid gcc!
View: Complete Thread (14 articles)
Original Format
Newsgroups: comp.lang.c
Date: 2002-06-20 09:12:10 PST


In <aerd8p$3s2$1@news.state.mn.us> zgene@hotmail.com writes:

>Look at this code:
>
>1. #include<stdio.h>
>2. 3. main()
>4. { const int *pc;
>5.  int i = 10;
>6.
>7.  pc = &i;
>8.  printf("%d\n", *pc);
>9.
>10.  int c = 2;
>11.  pc = &c;
>12.  printf("%d\n", *pc);
>13. }
>
>If I compile this code with gcc, I get:
>
>myprompt> gcc PtrTest.c
>PtrTest.c: In function `main':
>PtrTest.c:9: parse error before `int'
>PtrTest.c:10: `c' undeclared (first use in this function)
>PtrTest.c:10: (Each undeclared identifier is reported only once
>PtrTest.c:10: for each function it appears in.)
>myprompt>
>
>Whereas g++ compiles it nicely.  Look:
>
>myprompt> g++ PtrTest.c
>myprompt>
>
>However, if I move Line 10 to Line 6, gcc also compiles it nicely.
>
>So, does g want us to declare all variables at the head of a block?
>What a stupid gcc!

What a stupid poster!

The code is invalid as both a C89 program (the misplaced declaration) and a
C99 program (the implicit int for the return value type is no longer
supported).

Recent versions of gcc will actually silently accept your garbage, if
invoked in the default GNU C mode, but will diagnose it in either C89 and
C99 mode:

    fangorn:~/tmp 1085> gcc test.c
    fangorn:~/tmp 1086> gcc -ansi -pedantic test.c
    test.c: In function `main':
    test.c:10: warning: ISO C89 forbids mixed declarations and code
    fangorn:~/tmp 1087> gcc -std=c99 test.c
    test.c:4: warning: type defaults to `int' in declaration of `main'
    fangorn:~/tmp 1088> gcc -v
    Reading specs from 
/products/gnu/gcc3/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.0.3/specs
    Configured with: ./configure --prefix=/products/gnu/gcc3/v3.0
    Thread model: single
    gcc version 3.0.3

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de


-----Original Message-----
From: Colin Douglas Howell [mailto:chowell2@pacbell.net] 
Sent: Thursday, 23 October 2003 06:06
To: Jim Wilson
Cc: Nguyen, KhaiDinh; gcc@gcc.gnu.org
Subject: Re: cc and gcc compilers


Jim Wilson wrote:
> Nguyen, KhaiDinh wrote:
> 
>> We are migating many C programs from (old) NCR Unix system to AIX. 
>> These C programs are non-ansi standard and compiled by using NCR unix 
>> cc compiler.
> 
> 
> See http://gcc.gnu.org/bugs.html for info on how to report bugs.
> 
> This report is very confusing.  In one place you imply that the C code
> is very old, and thus pre-dates ANSI C (aka ISO C90).  In another place, 
> you imply that the code won't compile because it uses an ISO C99 
> feature, and thus post dates ANSI C (aka ISO C90).  Which is it?  A 
> testcase would be very helpful to eliminate the confusion.  If we don't 
> know what exact problem you are seeing, then we may not be able to help.

Jim,

I think you're misreading the situation.

Mr. Nguyen said that the system was an old NCR Unix system, not that the
code was pre-ANSI C.  (He said that the code was *non-ANSI*, not pre-ANSI.)
He also said that the code used features like "variable declared after
statements/variable assignments".  It turns out that this is a extension
provided by NCR's proprietary High Performance C/C++ Compiler.  This
compiler defines a language called High C which has a bunch of extensions to
ANSI standard C.  It can also operate in strict ANSI-compatible mode. Or it
can operate in a pre-ANSI compatible mode which also allows limited usage of
ANSI constructs and High C extensions.

I found a manual for this compiler, dated 12/1997, on NCR's web site:

http://www.info.ncr.com/eDownload.cfm?itemid=980790019&fulltxt=Yes

It's a PDF.  Page 305 of the manual describes the mixed declarations and
statements extension; this page is part of Appendix F, which starts on page
294 and describes the extensions provided by High C.

In short, it sounds like Mr. Nguyen's code uses NCR proprietary extensions.
For that code to work on other systems, those extensions must be removed. If
Mr. Nguyen's team is very lucky, the extensions they used might just happen
to fall under the new ISO C99 standard, so compiling in that mode might
work; more likely, they will have to convert the code themselves, possibly
with the help of automated scripts.  The NCR compiler may be able to help in
that conversion; for example, the -Hansi option enforces strict ANSI
compliance, and might be usable to flag usage of extensions; also some
specific compiler features can be controlled with toggles (I don't think
that mixing statements and declarations is one of those).

Colin


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

end of thread, other threads:[~2003-10-22 22:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-17  6:44 cc and gcc compilers Nguyen, KhaiDinh
2003-10-20 19:01 ` Per Bothner
2003-10-22 22:49 Nguyen, KhaiDinh

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).