Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Apr 1999 17:14:44 -0600
From:      "Drew Eckhardt" <drew@plutotech.com>
To:        freebsd-bugs@freebsd.org, egcs-bugs@cygnus.com
Message-ID:  <199904132314.RAA93619@pluto.plutotech.com>

next in thread | raw e-mail | index | archive | help

Under i86 FreeBSD 3.1-stable, using these  versions of g++

    gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
    gcc version 2.7.2.1

the BSD htonl macro which uses __extension__({}) can't be used in C++ 
constructor initializer lists.


The test program

    #include <sys/param.h>
    struct foo {
	foo (long x) : bar(htonl(x)) { }
	long bar;
    };


Expands to something like

    typedef unsigned long u_long;
    struct foo {
	foo (long x) : bar(__extension__ ({ register u_long __X = ( x ); __asm ("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" : "=q" (__X) : "0" (__X)); __X; }) ) { }
	long bar;
    };

and produces these errors

    htonl.cc:4: parse error before `)'
    htonl.cc:4: missing ';' before right brace
    htonl.cc:5: semicolon missing after declaration of `foo'
    htonl.cc: In method `foo::foo(long int)':
    htonl.cc:4: parse error at end of saved text
-- 
Work: <drew@plutotech.com>   | For those who don't, no explanation is possible.
Play: <drew@poohsticks.org>  | For those who do, no explanation is necessary.  
Home page: http://www.poohsticks.org/drew/">Home Page</a>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904132314.RAA93619>