# -pedantic gives loads of errors

This topic is 5039 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, after a while of programming in c++, using gnu g++ and djgpp gpp to compile, I decided that I wanted to test my program in windows. The program only consists out of basic c++ stuff (fors, whiles, some standard stdio and iostream and header files, nothing scary) so I'm pretty sure that this should be possible. But when I tried to compile it with the win32 compiler lcc I got loads of errors; so I decided to check if the code is in Ansi-C++. I tried adding the option -ansi in compiling and everything worked fine. I went searching on google and reading the man page of g++ and found that I had to use pedantic (is this true?). When I compiled with pedantic everything was still fine, but when I tried to link them I got loads of errors. I tried searching for people with the same problem and found a very old thread somewhere suggesting that the header files may be wrong. By the looks of it, mine were fine though. This is an example of one of my header files:
#include <stdio.h>

#ifndef _GUNZIP_H
#define _GUNZIP_H

FILE * decompress(FILE * fb);

#endif


And this is what happens when compile and (try to) link the object files:
C:\DOCUME~1\Bas\BUREAU~1\Project\2-1>gpp -Wall -c -ansi Main.cpp Gunzip.cpp Trac
ker.cpp Hash.cpp

C:\DOCUME~1\Bas\BUREAU~1\Project\2-1>gpp -Wall -o -ansi Main.exe Main.o Gunzip.o
Tracker.o Hash.o
Main.exe(.text+0x208):crt0.s: multiple definition of ___exit'
c:/djgpp/lib/crt0.o(.text+0x200):crt0.s: first defined here
Main.exe(.text+0x2e8):crt0.s: multiple definition of ___sbrk'
c:/djgpp/lib/crt0.o(.text+0x2e0):crt0.s: first defined here
Main.exe(.text+0x50e):crt0.s: multiple definition of __crt0_init_mcount'
c:/djgpp/lib/crt0.o(.text+0x506):crt0.s: first defined here
Main.exe(.text+0x300):crt0.s: multiple definition of ___brk'
c:/djgpp/lib/crt0.o(.text+0x2f8):crt0.s: first defined here
Main.exe(.text+0x8):crt0.s: multiple definition of start'
c:/djgpp/lib/crt0.o(.text+0x0):crt0.s: first defined here
Main.o(.text+0x2ea):Main.cpp: multiple definition of _main'
cpp:17: first defined here
Main.exe(.bss+0x38):Main.cpp: first defined here
Gunzip.o(.bss+0x84):Gunzip.cpp: multiple definition of _buffer'
Main.exe(.bss+0xbc):Main.cpp: first defined here
Gunzip.o(.bss+0x88):Gunzip.cpp: multiple definition of _bitPos'
Main.exe(.bss+0xc0):Main.cpp: first defined here
Gunzip.o(.bss+0x8c):Gunzip.cpp: multiple definition of _intPos'
Main.exe(.bss+0xc4):Main.cpp: first defined here
Gunzip.o(.text+0x104):Gunzip.cpp: multiple definition of decompress(FILE*)'
p.cpp:70: first defined here
Gunzip.o(.text+0x2298):Gunzip.cpp: multiple definition of setBitMask()'
ip.cpp:515: first defined here
Gunzip.o(.text+0x255e):Gunzip.cpp: multiple definition of getValue(int)'
ip.cpp:581: first defined here
Gunzip.o(.text+0x22fa):Gunzip.cpp: multiple definition of Huffman::makeEncoding
(int, int*)'
ip.cpp:529: first defined here
Gunzip.o(.text+0x268e):Gunzip.cpp: multiple definition of getCode(Huffman*)'
ip.cpp:611: first defined here
Gunzip.o(.text+0x27bc):Gunzip.cpp: multiple definition of CRC32(FILE*)'
ip.cpp:632: first defined here
Tracker.o(.text+0x104):Tracker.cpp: multiple definition of Tracker::~Tracker()'

ker.cpp:35: first defined here
Tracker.o(.text+0x130):Tracker.cpp: multiple definition of Tracker::deAlloc()'
ker.cpp:40: first defined here
Tracker.o(.text+0x11a):Tracker.cpp: multiple definition of Tracker::~Tracker()'

ker.cpp:35: first defined here
Tracker.o(.text+0x29c):Tracker.cpp: multiple definition of Tracker::trackFile(c
har*)'
ker.cpp:55: first defined here
Tracker.o(.text+0x2238):Tracker.cpp: multiple definition of Tracker::lcase(char
)'
ker.cpp:479: first defined here
Tracker.o(.text+0xb34):Tracker.cpp: multiple definition of Tracker::control_e()
'
ker.cpp:181: first defined here
Tracker.o(.text+0xcd0):Tracker.cpp: multiple definition of Tracker::control_d()
'
ker.cpp:200: first defined here
Tracker.o(.text+0xee4):Tracker.cpp: multiple definition of Tracker::control_l()
'
ker.cpp:213: first defined here
Tracker.o(.text+0x802):Tracker.cpp: multiple definition of Tracker::getWord_siz
e()'
ker.cpp:136: first defined here
Tracker.o(.text+0x8b0):Tracker.cpp: multiple definition of Tracker::getWord(int
)'
ker.cpp:148: first defined here
Tracker.o(.text+0x1160):Tracker.cpp: multiple definition of Tracker::check_word
s(char*)'
ker.cpp:225: first defined here
Tracker.o(.text+0x946):Tracker.cpp: multiple definition of Tracker::getInt()'
ker.cpp:157: first defined here
Tracker.o(.text+0xa08):Tracker.cpp: multiple definition of Tracker::getLong()'
ker.cpp:169: first defined here
Tracker.o(.text+0x164c):Tracker.cpp: multiple definition of Tracker::announce_l
ist_list_end()'
ker.cpp:307: first defined here
Tracker.o(.text+0x15f6):Tracker.cpp: multiple definition of Tracker::do_announc
e_list_next_announce(char*, int)'
ker.cpp:300: first defined here
Tracker.o(.text+0x1f42):Tracker.cpp: multiple definition of Tracker::do_info_fi
les_next_path(char*, int)'
ker.cpp:431: first defined here
Tracker.o(.text+0x225c):Tracker.cpp: multiple definition of Tracker::lcase(char
*)'
ker.cpp:485: first defined here
Tracker.o(.text+0x14e0):Tracker.cpp: multiple definition of Tracker::do_announc
e()'
ker.cpp:282: first defined here
Tracker.o(.text+0x154c):Tracker.cpp: multiple definition of Tracker::do_announc
e_list()'
ker.cpp:290: first defined here
Tracker.o(.text+0x16f8):Tracker.cpp: multiple definition of Tracker::do_creatio
n_date()'
ker.cpp:319: first defined here
Tracker.o(.text+0x177a):Tracker.cpp: multiple definition of Tracker::do_comment
()'
ker.cpp:324: first defined here
Tracker.o(.text+0x17e4):Tracker.cpp: multiple definition of Tracker::do_created
_by()'
ker.cpp:331: first defined here
Tracker.o(.text+0x184e):Tracker.cpp: multiple definition of Tracker::do_info()'

ker.cpp:338: first defined here
Tracker.o(.text+0x2048):Tracker.cpp: multiple definition of Tracker::discard()'

ker.cpp:442: first defined here
Tracker.o(.text+0x1a36):Tracker.cpp: multiple definition of Tracker::do_info_le
ngth()'
ker.cpp:376: first defined here
Tracker.o(.text+0x1b10):Tracker.cpp: multiple definition of Tracker::do_info_na
me()'
ker.cpp:386: first defined here
Tracker.o(.text+0x1b7a):Tracker.cpp: multiple definition of Tracker::do_info_pi
ece_length()'
ker.cpp:393: first defined here
Tracker.o(.text+0x1bfc):Tracker.cpp: multiple definition of Tracker::do_info_pi
eces()'
ker.cpp:398: first defined here
Tracker.o(.text+0x1c8e):Tracker.cpp: multiple definition of Tracker::do_info_fi
les()'
ker.cpp:406: first defined here
Tracker.o(.text+0x1dac):Tracker.cpp: multiple definition of Tracker::do_info_fi
les_length()'
ker.cpp:414: first defined here
Tracker.o(.text+0x1e38):Tracker.cpp: multiple definition of Tracker::do_info_fi
les_path()'
ker.cpp:419: first defined here
Tracker.o(.text+0x234c):Tracker.cpp: multiple definition of Tracker::printTrack
er()'
ker.cpp:493: first defined here
Hash.o(.text+0x104):Hash.cpp: multiple definition of rotl(unsigned int, int)'
.cpp:15: first defined here
Hash.o(.text+0x13e):Hash.cpp: multiple definition of hash(char*, int)'
.cpp:21: first defined here
collect2: ld returned 1 exit status

C:\DOCUME~1\Bas\BUREAU~1\Project\2-1>


I hope someone here knows what is going wrong and how I can convert the code to ANSI-C++. By the way, without the -pedantic stuff everything does work fine. Thanx for reading, Bas

##### Share on other sites
-o -ansi Main.exe should be -ansi -o Main.exe

Otherwise, you are creating an executable named '-ansi' and actually link with Main.exe (leftover from previous compilations I presume) - hence the multiple definition errors.

##### Share on other sites
Thanx Fruny! That was it :)

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 49
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632965
• Total Posts
3009546
• ### Who's Online (See full list)

There are no registered users currently online

×