Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* errno.h problems in DEC 'C'
@ 1995-08-02  4:00 Greg Thomas
  1995-08-02  4:00 ` Lawrence Kirby
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Greg Thomas @ 1995-08-02  4:00 UTC (permalink / raw)


Hi,

I'm trying to porting some code to Alpha/DEC 'C' from VAX/VAX 'C'. We have, 
however, hit a problem with the <errno.h> include file. It #defines it to be 
(*cma$tis_errno_get_addr()). The trouble is, we have number of structures that 
have an errno as an element. Of course, this gets expanded to the above 
function, and so it won't compile. ie ...

#include <errno.h>

/* Which then does the following define ... 
#define errno (*cma$tis_errno_get_addr())
*/

struct test 
{
	long errno;
/* which gets expanded to 
	long (*cma$tis_errno_get_addr());
   which of course will not compile 
*/
};

Now whilst I can change all our code to not refer to errno in this structure, 
I feel that the DEC 'C' errno.h does not have correct behaviour in it. Is the 
DEC 'C' compiler in error (my K&R 2nd Ed does refer to errno as an integer, 
but that's all), or am I not allowed to do this?

Thanks for any help,


Greg Thomas
---
Tel (01473) 224832
Fax (01473) 233319



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

* Re: errno.h problems in DEC 'C'
  1995-08-02  4:00 errno.h problems in DEC 'C' Greg Thomas
@ 1995-08-02  4:00 ` Lawrence Kirby
  1995-08-02  4:00 ` Dan Pop
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Lawrence Kirby @ 1995-08-02  4:00 UTC (permalink / raw)


In article <3vo921$n4a@pheidippides.axion.bt.co.uk>
           thomasgd@boat.bt.com "Greg Thomas" writes:

>Now whilst I can change all our code to not refer to errno in this structure, 
>I feel that the DEC 'C' errno.h does not have correct behaviour in it. Is the 
>DEC 'C' compiler in error (my K&R 2nd Ed does refer to errno as an integer, 
>but that's all), or am I not allowed to do this?

From the standard

"It is unspecified whether errno is a macro or an identifier declared with
external linkage. If a macro definition is suppressed in order to access an
actual object, or the program defines an identifier with the name errno,
the behaviour is undefined".

Given that and the fact that a structure member name is an identifier
Dec 'C's implementation is correct and the fault is with the code.

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------



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

* Re: errno.h problems in DEC 'C'
  1995-08-02  4:00 errno.h problems in DEC 'C' Greg Thomas
  1995-08-02  4:00 ` Lawrence Kirby
@ 1995-08-02  4:00 ` Dan Pop
  1995-08-03  4:00   ` halasz
  1995-08-02  4:00 ` J. Daniel Smith
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Dan Pop @ 1995-08-02  4:00 UTC (permalink / raw)


In <3vo921$n4a@pheidippides.axion.bt.co.uk> thomasgd@boat.bt.com (Greg Thomas) writes:

>Hi,
>
>I'm trying to porting some code to Alpha/DEC 'C' from VAX/VAX 'C'. We have, 
>however, hit a problem with the <errno.h> include file. It #defines it to be 
>(*cma$tis_errno_get_addr()). The trouble is, we have number of structures that 
>have an errno as an element. Of course, this gets expanded to the above 
>function, and so it won't compile. ie ...
>
You got precisely what you deserved.

>Now whilst I can change all our code to not refer to errno in this structure, 
>I feel that the DEC 'C' errno.h does not have correct behaviour in it. Is the 
>DEC 'C' compiler in error (my K&R 2nd Ed does refer to errno as an integer, 
>but that's all), or am I not allowed to do this?

It's all your fault.  Here's the relevant part of the standard:

    4.1.3 Errors <errno.h>

    The header <errno.h> defines several macros, all relating to the
    reporting of error conditions.

       The macros are 
           ^^^^^^
	     EDOM
	     ERANGE

    which expand to distinct nonzero integral constant expressions; and 

	     errno

    which expands to a modifiable lvalue that has type int...
          ^^^^^^^

(*cma$tis_errno_get_addr()) looks like a modifiable lvalue, so the 
implementation is correct (the cma$tis_errno_get_addr symbol is
definitely not in the user's namespace).

Time to fix your code.

Dan
--
Dan Pop
CERN, CN Division
Email: Dan.Pop@mail.cern.ch 
Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



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

* Re: errno.h problems in DEC 'C'
  1995-08-02  4:00 errno.h problems in DEC 'C' Greg Thomas
  1995-08-02  4:00 ` Lawrence Kirby
  1995-08-02  4:00 ` Dan Pop
@ 1995-08-02  4:00 ` J. Daniel Smith
  1995-08-03  4:00 ` David Claude Brown
  1995-08-03  4:00 ` Derick J.R. Qua-Gonzalez
  4 siblings, 0 replies; 9+ messages in thread
From: J. Daniel Smith @ 1995-08-02  4:00 UTC (permalink / raw)


In <3vo921$n4a@pheidippides.axion.bt.co.uk> thomasgd@boat.bt.com (Greg Thomas) writes:
>however, hit a problem with the <errno.h> include file. It #defines it to be 
>(*cma$tis_errno_get_addr()). The trouble is, we have number of structures that 
the compiler is allowed to do this, ANSI 4.1.3.

>I feel that the DEC 'C' errno.h does not have correct behaviour in it. Is the 
>DEC 'C' compiler in error (my K&R 2nd Ed does refer to errno as an integer, 
>but that's all), or am I not allowed to do this?
you'll hardly ever find ANSI C problems with the DEC C compiler, if
it complains chances are excellent your code is at fault.

   Dan
-- 
--------------------- message is author's opinion only --------------------
J. Daniel Smith <dan@bristol.com>               http://www.bristol.com/~dan
Bristol Technology Inc.	                    +1 203 438 6969, 438-5013 (FAX)
Ridgefield, Connecticut (USA)                       {info,jobs}@bristol.com



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

* Re: errno.h problems in DEC 'C'
  1995-08-02  4:00 errno.h problems in DEC 'C' Greg Thomas
                   ` (2 preceding siblings ...)
  1995-08-02  4:00 ` J. Daniel Smith
@ 1995-08-03  4:00 ` David Claude Brown
  1995-08-03  4:00 ` Derick J.R. Qua-Gonzalez
  4 siblings, 0 replies; 9+ messages in thread
From: David Claude Brown @ 1995-08-03  4:00 UTC (permalink / raw)


In article <3vo921$n4a@pheidippides.axion.bt.co.uk> thomasgd@boat.bt.com (Greg Thomas) writes:

>I'm trying to porting some code to Alpha/DEC 'C' from VAX/VAX 'C'. We have, 
>however, hit a problem with the <errno.h> include file. It #defines it to be 
>(*cma$tis_errno_get_addr()). The trouble is, we have number of structures that 
>have an errno as an element. Of course, this gets expanded to the above 
>function, and so it won't compile. ie ...

[snip]

>Now whilst I can change all our code to not refer to errno in this structure, 
>I feel that the DEC 'C' errno.h does not have correct behaviour in it. Is the 
>DEC 'C' compiler in error (my K&R 2nd Ed does refer to errno as an integer, 
>but that's all), or am I not allowed to do this?

DEC are allowed to do this. Paraphrasing the standard ("Reserved Identifiers" 
and "Errors <errno.h>")

  -   when <errno.h> is included, the identifier 'errno' is a reserved
      identifier.

  -   errno may be a macro; regardless it must result in a modifiable
      lvalue of type 'int'

They even give an example in a footnote not unlike DEC's implmentation.

Claude.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 vv    vv       David Claude Brown
 ||----||  *    brown@falam.ch
 ||     | /
 /\------/
(oo)
(~~)



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

* Re: errno.h problems in DEC 'C'
  1995-08-02  4:00 ` Dan Pop
@ 1995-08-03  4:00   ` halasz
  1995-08-04  4:00     ` Dan Pop
  1995-08-04  4:00     ` David Claude Brown
  0 siblings, 2 replies; 9+ messages in thread
From: halasz @ 1995-08-03  4:00 UTC (permalink / raw)


In article <danpop.807407394@rscernix>, Dan.Pop@mail.cern.ch (Dan Pop) writes
! It's all your fault.  Here's the relevant part of the standard:
! 
!     4.1.3 Errors <errno.h>
! 
!     The header <errno.h> defines several macros, all relating to the
!     reporting of error conditions.
! 
!        The macros are 
!            ^^^^^^
! 	     EDOM
! 	     ERANGE
! 
!     which expand to distinct nonzero integral constant expressions; and 
! 
! 	     errno
! 
!     which expands to a modifiable lvalue that has type int...
!           ^^^^^^^

The standard looks wrong to me ....
full of traps for the innocent.



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

* Re: errno.h problems in DEC 'C'
  1995-08-02  4:00 errno.h problems in DEC 'C' Greg Thomas
                   ` (3 preceding siblings ...)
  1995-08-03  4:00 ` David Claude Brown
@ 1995-08-03  4:00 ` Derick J.R. Qua-Gonzalez
  4 siblings, 0 replies; 9+ messages in thread
From: Derick J.R. Qua-Gonzalez @ 1995-08-03  4:00 UTC (permalink / raw)


thomasgd@boat.bt.com (Greg Thomas) writes: I'm trying to porting some
>code to Alpha/DEC 'C' from VAX/VAX 'C'. We have, however, hit a
>problem with the <errno.h> include file. It #defines it to be
>(*cma$tis_errno_get_addr()). The trouble is, we have number of
>structures that have an errno as an element. Of course, this gets
>expanded to the above function, and so it won't compile. ie ...

The problem is because ISO does not allow "$" in identifiers, but _some_
compilers do in order to access system-defined identifiers with "$" in
them---VAX VMS is notably one that has a few (do I remember SMG$ cor-
rectly?). Just a guess, but are you including the correct headers for
your _current_ compiler?

Best regards,
Derick.
--
+-----------------------------------------------------------------------------+
| Derick R. Qua-Gonzalez                                           | ________ |
| Department of High Energy Physics, California State University   | \      / |
| dqua@EarthLink.Net                                               |  \    /  |
|        ``It is better to be hated for what one is,               |   \  /   |
|          than loved for what one is not.'' (A. Gide)             | G  \/ USA|
+------------------------------------------------------------------+----------+
| mQBNAy/qJJMAAAECANBCB543eTUkdG8Mqx6K2cm3WxCVtKY8ZbB9WY6A2Ne4dQi8 | PGP2.6.2 |
| xh7OxjHXP/eXp5BSbmVAihEGd7r+5g/yknko56kABRG0MERKUiBRdWEtR29uemFs |  Public  |
| ZXogPGRxdWFAUHJvbWV0aGV1cy5FYXJ0aGxpbmsuTmV0Pg==                 | KeyBlock |
| =70DW                                                            | 06.20.95 |
+------------------------------------------------------------------+----------+



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

* Re: errno.h problems in DEC 'C'
  1995-08-03  4:00   ` halasz
@ 1995-08-04  4:00     ` Dan Pop
  1995-08-04  4:00     ` David Claude Brown
  1 sibling, 0 replies; 9+ messages in thread
From: Dan Pop @ 1995-08-04  4:00 UTC (permalink / raw)


In <3vqrg1$bem@caip.rutgers.edu> halasz@caip.rutgers.edu writes:

>In article <danpop.807407394@rscernix>, Dan.Pop@mail.cern.ch (Dan Pop) writes
>! It's all your fault.  Here's the relevant part of the standard:
>! 
>!     4.1.3 Errors <errno.h>
>! 
>!     The header <errno.h> defines several macros, all relating to the
>!     reporting of error conditions.
>! 
>!        The macros are 
>!            ^^^^^^
>! 	     EDOM
>! 	     ERANGE
>! 
>!     which expand to distinct nonzero integral constant expressions; and 
>! 
>! 	     errno
>! 
>!     which expands to a modifiable lvalue that has type int...
>!           ^^^^^^^
>
>The standard looks wrong to me ....
>full of traps for the innocent.

The standard is, by definition, right :-)
C is not for the innocent :-)

Dan
--
Dan Pop
CERN, CN Division
Email: Dan.Pop@mail.cern.ch 
Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



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

* Re: errno.h problems in DEC 'C'
  1995-08-03  4:00   ` halasz
  1995-08-04  4:00     ` Dan Pop
@ 1995-08-04  4:00     ` David Claude Brown
  1 sibling, 0 replies; 9+ messages in thread
From: David Claude Brown @ 1995-08-04  4:00 UTC (permalink / raw)


In article <3vqrg1$bem@caip.rutgers.edu> halasz@caip.rutgers.edu writes:
>In article <danpop.807407394@rscernix>, Dan.Pop@mail.cern.ch (Dan Pop) writes
>! It's all your fault.  Here's the relevant part of the standard:
>! 
>!     4.1.3 Errors <errno.h>
>! 
>!     The header <errno.h> defines several macros, all relating to the
>!     reporting of error conditions.
>! 
>!        The macros are 
>!            ^^^^^^
>!            EDOM
>!            ERANGE
>! 
>!     which expand to distinct nonzero integral constant expressions; and 
>! 
>!            errno
>! 
>!     which expands to a modifiable lvalue that has type int...
>!           ^^^^^^^

>The standard looks wrong to me ....
>full of traps for the innocent.

The innocent would not use identifiers defined by the standard for their own 
purposes even if the standard allowed them too.

Name space management is _extremely_ important (IMHO) and is one of VMS's 
strengths. Perhaps the people who wrote the original 'errno' member had 
been lulled by VMS into thinking that they could do no wrong (no $ => OK)

I suggest a global subsititute of '.errno' and '->errno' to a new name as a 
first pass.  These two strings won't show up very often (if at all) in your 
programs other than in the places that you want to change them.

Claude.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 vv    vv       David Claude Brown
 ||----||  *    brown@falam.ch
 ||     | /
 /\------/
(oo)
(~~)



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

end of thread, other threads:[~1995-08-04  4:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-08-02  4:00 errno.h problems in DEC 'C' Greg Thomas
1995-08-02  4:00 ` Lawrence Kirby
1995-08-02  4:00 ` Dan Pop
1995-08-03  4:00   ` halasz
1995-08-04  4:00     ` Dan Pop
1995-08-04  4:00     ` David Claude Brown
1995-08-02  4:00 ` J. Daniel Smith
1995-08-03  4:00 ` David Claude Brown
1995-08-03  4:00 ` Derick J.R. Qua-Gonzalez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox