| delorie.com/archives/browse.cgi | search |
| From: | Mark Phillips <umphill5 AT cs DOT umanitoba DOT ca> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | and another thing... |
| Date: | Wed, 26 May 1999 11:56:59 -0500 |
| Organization: | The University of Manitoba |
| Lines: | 47 |
| Message-ID: | <Pine.SUN.3.96.990526115225.18233A-100000@silver.cs.umanitoba.ca> |
| NNTP-Posting-Host: | silver.cs.umanitoba.ca |
| Mime-Version: | 1.0 |
| X-Trace: | canopus.cc.umanitoba.ca 927737827 14616 130.179.24.6 (26 May 1999 16:57:07 GMT) |
| X-Complaints-To: | Postmaster AT cc DOT umanitoba DOT ca |
| NNTP-Posting-Date: | 26 May 1999 16:57:07 GMT |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Why should I get this:
Compiling: h.cc
no errors
Compiling: main.cc
no errors
Creating: test.exe
Error: main.o(.data+0x0):main.cc: multiple definition of 'foo'
Error: h.o(.data+0x0):h.cc first defined here
When I do this:
// file #1 main.cc
#include "header.h"
int main()
{
fun1();
return 0;
}
// file #2 h.cc
#include "header.h"
void fun1()
{
foo = 1;
}
// file #3 header.h
#ifndef HEADER_H
#define HEADER_H
void fun1();
bool foo;
#endif
Shouldn't the preprocessor directives in 'header.h' handle the multiple
declaration linking errors?
love
mark
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |