[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

2098.0. "Invalid enumerator" by RTOMS::PARETIJ () Thu Feb 20 1997 06:40

Unix V4.0 564 alpha  
--------------------

In a C code the following message appears :

cc: Error: /space/tuebingen/num/inc//basis.h, line 90: Invalid enumerator.
 typedef enum {FALSE, TRUE} boolean;

I compiled as follows 

cc -O1 -I/space/tuebingen/num/inc/ -Dlint 

using lint -std0,1 didn't help. Any suggestion ?

Thanks
/Joseph

T.RTitleUserPersonal
Name
DateLines
2098.1FALSE, TRUE may be already definedTAVENG::BORISBoris Gubenko, ISEThu Feb 20 1997 07:3814
  Check if FALSE, TRUE are already defined. For example, from <stdio.h>:

/*
**  DEC C RTL extension.  Define the values TRUE and FALSE.
*/
#ifndef _ANSI_C_SOURCE
#   ifndef TRUE
#      define TRUE 1
#   endif
#   ifndef FALSE
#      define FALSE 0
#   endif
#endif
2098.2Standard header "namespace pollution" ?DECC::SULLIVANJeff SullivanThu Feb 20 1997 11:1120
I ran into this exact problem while compiling some code that works fine on
Microsoft and other UNIX vendors. The workaround (as suggested in .1) is to add
-D_ANSI_C_SOURCE to the command line. The problem(?) is within stdio.h.

I am not sure I agree with having to add -D_ANSI_C_SOURCE to the command line to
eliminate "namespace pollution" when #including the "standard" header files.
This is just another issue that developers face when porting applications from
elsewhere to Digital UNIX.

Fwiw, I was able to get lint to crash with my simple test program (due to the
enum "syntax error"). I have reported that and it will be fixed in Steel (the
next major release after Digital UNIX V4.0).

If others agree that the standard header "namespace pollution" is an issue that
needs to be addressed in this case, I'd be happy to report an OSF_QAR against
the offending header file.

-Jeff


2098.3not only OSF_QARTAVENG::BORISBoris Gubenko, ISEThu Feb 20 1997 13:1516
  On OpenVMS the only offending standard header (as far as the TRUE and FALSE
  identifiers are concerned :-) is <stdio.h>.

  I'm not sure, that this is a bug because these identifiers are hidden in a 
  strict ANSI mode or when any of _ANSI_C_SOURCE, _XOPEN_SOURCE,
  _POSIX_C_SOURCE or _XOPEN_SOURCE_EXTENDED is defined.

  I think, this is a matter of the default compiler mode. Since the default on
  OpenVMS is /STANDARD=RELAXED_ANSI89 where TRUE and FALSE are visible, I
  think, that we should remove them from the header.

  Generally speaking, it seems to me, that in a standard header we shouldn't
  declare identifiers which is not reserved for the use by the implementation
  by any standard even if they are invisible in a ANSI/XOPEN/POSIX mode.

  Boris
2098.4WHOS01::BOWERSDave Bowers, NSIS/IMThu Feb 20 1997 14:397
    re .3;
    
    Removing these definitions will, of course, break a lot of existing C
    code on VMS, where people have come to rely on them. 
    
    \dave
    
2098.5Reply .4TAVENG::BORISBoris Gubenko, ISEThu Feb 20 1997 18:169
>     Removing these definitions will, of course, break a lot of existing C
>     code on VMS, where people have come to rely on them. 

    Some people obviously will have to define TRUE and FALSE in their sources
    if the header will change. On the other hand, one won't need to change an
    ANSI-compliant code from another vendor referencing these identifiers in
    order to have clean compilation in the default compiler mode.

    Boris
2098.6problem solved; next problemRTOMS::PARETIJFri Feb 21 1997 05:5419
Great ! compiling with -D_ANSI_C_SOURCE solved the
invalid enumerator problem.

I get now the following fault on this code 
- that in the mind of the customer is meant to exercise
the compiler ...

cc: Error: /space/tuebingen/num/15/gax.c, line 167: In this statement, "Fields"
is not declared.
  Fields = (IntInfo **)vmalloc(vmblock, VVEKTOR,

where :

   167    Fields = (IntInfo **)vmalloc(vmblock, VVEKTOR,
   168                                 Maximum, sizeof(*Fields));
   169    if (! vmcomplete(vmblock))
   170      return 8;

etc.
2098.7-source_listing -show allMUCTEC::BECKERHartmut B., VMS &amp; Languages, MunichFri Feb 21 1997 07:349
Have a look at your source, it should be declared somewhere. Or even better
look at a compiler generated source listing.  VMS people do that, they let
the compiler generate a listing with all the source lines all the include
files and all the macro expansions. Then they load it into an appropriate
editor and look for definitions, declarations conditionals etc. You can do
that with decc aka -migrate: -source_listing -show all         

Hope this helps,
Hartmut
2098.8DECCXL::OUELLETTEFri Feb 21 1997 14:5410
OK.  The compiler group will assume that your missing Fields declaration
is a user error which you will fix unless we hear otherwise.

My favorite way of looking at these things is to add -E > gax.preproc
to my compile command line and then to edit the preprocessor output
next to the source.  I can usually then tell what's up.
-source_listing -show all is equivalent, but I'm not fond of 132 column
listing files.

R.