Unix
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Unix

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old May 25th, 2008, 01:19 PM
Samuel Thibault
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
error_t, E*, and c++

Hello,

The following can not compile with g++ on GNU/Hurd:

#include <errno.h>
int main(void) {
error_t = EPERM;
}

test.c:9: error: invalid conversion from 'int' to 'error_t'

That is because errno.h #defines EPERM to _HURD_ERRN(1), and then g++
complains because error_t is an enum.

I guess we should for instance make all the #defines #ifndef __cplusplus?

Samuel

Reply With Quote
  #2  
Old May 27th, 2008, 06:10 AM
Samuel Thibault
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
error_t, E*, and c++

Samuel Thibault, le Tue 27 May 2008 11:01:29 +0100, a :
Roland McGrath, le Mon 26 May 2008 20:01:17 -0700, a :
But I think we might just have to live with
C++ using (error_t) EF,

A friend of mine suggested to rather use error_t(EF), which is a bit
less dirty but still works.

(and it makes sense, as the standard says that E* are just ints).

Samuel

Reply With Quote
  #3  
Old May 27th, 2008, 06:10 AM
Samuel Thibault
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
error_t, E*, and c++

Roland McGrath, le Mon 26 May 2008 20:01:17 -0700, a :
(The error_t usage being broken in C++ is at least not a silent change
or breakage of something that already works.)

True for us, but it does work on e.g. Linux since error_t is typedefed
to int there :/

It may also be a problem in some other C++ way I'm not aware of off
hand, for the type of EF not to be int.

I'm open to suggestions. But I think we might just have to live with
C++ using (error_t) EF, or else supply a C++ <errnoor whatever where
there is explicitly no expectation of int-valued or cpp-usable values,
if people would actually use that.

, so that means we have to raise the issue at the C++ language level :/

Thanks,
Samuel

Reply With Quote
  #4  
Old May 27th, 2008, 06:10 AM
Samuel Thibault
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
error_t, E*, and c++

Roland McGrath, le Mon 26 May 2008 20:01:17 -0700, a :
But I think we might just have to live with
C++ using (error_t) EF,

A friend of mine suggested to rather use error_t(EF), which is a bit
less dirty but still works.

or else supply a C++ <errnoor whatever where there is explicitly
no expectation of int-valued or cpp-usable values, if people would
actually use that.

That would be less easy to get accepted I guess.

Samuel

Reply With Quote
  #5  
Old May 27th, 2008, 05:10 PM
Roland McGrath
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
error_t, E*, and c++

Hmm. You need at least "#define EF EF" to make "#ifdef EF" work.
But one of the reasons for the current style of definition is in
particular so that "#if EAGAIN != EWULDBLCK" works right. That can
only win if it's a cpp-interpretable expression, which cannot use enum
constants or syntax like casts. (The cpp rules mean that the enum
constants are unknown identifiers and treated as zero, so any EF ==
EBAR comparison says they are equal.) I am hesitant to risk breaking
any such #if expressions now compiled in C++ on Hurd. (The error_t
usage being broken in C++ is at least not a silent change or breakage of
something that already works.)

It may also be a problem in some other C++ way I'm not aware of off
hand, for the type of EF not to be int.

I'm open to suggestions. But I think we might just have to live with
C++ using (error_t) EF, or else supply a C++ <errnoor whatever where
there is explicitly no expectation of int-valued or cpp-usable values,
if people would actually use that.


Thanks,
Roland

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Unix > error_t, E*, and c++


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway