bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(Sem Assunto)


From: etg
Subject: (Sem Assunto)
Date: Sun, 12 Nov 2000 2:01:07 GMT

This code doesn't link with g++,but it links if the files
are .c instead of cpp(or with the -x c option).
The reason for that is a variable declaration in the
header file. It is only critical when the header file is
included twice and it seems the #ifndef ... #endif is
worthless. Once I should not change the header file I'm
using, maybe there is a way to make it work.
oce I'm porting c code to c++, it hard to change all the
files I'm using to make it work;
I didn't find anything about similar problems in the
documentation, maybe it's a simple task to solve it but I
can't figure a way. Let me know if it's not a bug but only
simple ingorance !!

I compiled it like this :
g++ main.cpp treta.cpp -o m

The linker complains about
multiple definition of 'treta'

// main.cpp:
#include "treta.h"
void main(void){}

//treta.cpp:
#include "treta.h"
int tretas(void){}

//treta.h:
#ifndef TRETA_H
#define TRETA_H

        int treta;
        int tretas(void);

#endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]