Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jul 2000 01:43:26 -0700 (PDT)
From:      xyf@stocke.com
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   gnu/20004: FBSD4 gcc __attribute__(constructor) not work
Message-ID:  <20000718084326.C023937BCA3@hub.freebsd.org>

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

>Number:         20004
>Category:       gnu
>Synopsis:       FBSD4 gcc __attribute__(constructor) not work
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 18 01:50:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     xuyifeng
>Release:        FreeBSD 4.0-stable
>Organization:
stocke.com
>Environment:
FreeBSD xyf.websoft.com.cn 4.0-RELEASE FreeBSD 4.0-RELEASE #1:Mon Jul 
17 13:22:57 CST 2000 root@xyf.websoft.com.cn:/usr/src/sys/compile/TEST i386
>Description:
the GNU C++ compiler in FreeBSD doesn't correctly handles "__attribute__((constructor))", but it works if I use C compiler instead.


>How-To-Repeat:
this is the demo program:

#include <stdio.h>
int g_int = 0;
void init() __attribute__((constructor));
void init()
{
    g_int = 1;
}

int main(int argc, char** argv)
{
    if (g_int == 1)
        printf("__attribute__((constructor)) work!\n");
    else
        printf("__attribute__((constructor)) not work!\n");

    return 0;
}

if the source program name is test.cpp and use command "c++ test.cpp" to compile it, "__attribute__((constructor))" hasn't effect,  but if the source program name is test.c, then use command "cc test.c" the compile it, it works!

>Fix:
I think some utilities in FreeBSD are inconsistent, it has different version of utilities for C and C++, need update these utilities.



>Release-Note:
>Audit-Trail:
>Unformatted:


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?20000718084326.C023937BCA3>