Jump to content
  • Advertisement
Sign in to follow this  
basananas

-pedantic gives loads of errors

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

If you intended to correct an error in the post then please contact us.

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'
Main.exe(.text+0x802):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Main.
cpp:17: first defined here
Gunzip.o(.bss+0x0):Gunzip.cpp: multiple definition of `_bitmask'
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*)'
Main.exe(.text+0xdac):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Gunzi
p.cpp:70: first defined here
Gunzip.o(.text+0x2298):Gunzip.cpp: multiple definition of `setBitMask()'
Main.exe(.text+0x2f40):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Gunz
ip.cpp:515: first defined here
Gunzip.o(.text+0x255e):Gunzip.cpp: multiple definition of `getValue(int)'
Main.exe(.text+0x3206):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Gunz
ip.cpp:581: first defined here
Gunzip.o(.text+0x22fa):Gunzip.cpp: multiple definition of `Huffman::makeEncoding
(int, int*)'
Main.exe(.text+0x2fa2):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Gunz
ip.cpp:529: first defined here
Gunzip.o(.text+0x268e):Gunzip.cpp: multiple definition of `getCode(Huffman*)'
Main.exe(.text+0x3336):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Gunz
ip.cpp:611: first defined here
Gunzip.o(.text+0x27bc):Gunzip.cpp: multiple definition of `CRC32(FILE*)'
Main.exe(.text+0x3464):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Gunz
ip.cpp:632: first defined here
Tracker.o(.text+0x104):Tracker.cpp: multiple definition of `Tracker::~Tracker()'

Main.exe(.text+0x377c):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:35: first defined here
Tracker.o(.text+0x130):Tracker.cpp: multiple definition of `Tracker::deAlloc()'
Main.exe(.text+0x37a8):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:40: first defined here
Tracker.o(.text+0x11a):Tracker.cpp: multiple definition of `Tracker::~Tracker()'

Main.exe(.text+0x3792):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:35: first defined here
Tracker.o(.text+0x29c):Tracker.cpp: multiple definition of `Tracker::trackFile(c
har*)'
Main.exe(.text+0x3914):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:55: first defined here
Tracker.o(.text+0x2238):Tracker.cpp: multiple definition of `Tracker::lcase(char
)'
Main.exe(.text+0x58b0):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:479: first defined here
Tracker.o(.text+0xb34):Tracker.cpp: multiple definition of `Tracker::control_e()
'
Main.exe(.text+0x41ac):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:181: first defined here
Tracker.o(.text+0xcd0):Tracker.cpp: multiple definition of `Tracker::control_d()
'
Main.exe(.text+0x4348):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:200: first defined here
Tracker.o(.text+0xee4):Tracker.cpp: multiple definition of `Tracker::control_l()
'
Main.exe(.text+0x455c):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:213: first defined here
Tracker.o(.text+0x802):Tracker.cpp: multiple definition of `Tracker::getWord_siz
e()'
Main.exe(.text+0x3e7a):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:136: first defined here
Tracker.o(.text+0x8b0):Tracker.cpp: multiple definition of `Tracker::getWord(int
)'
Main.exe(.text+0x3f28):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:148: first defined here
Tracker.o(.text+0x1160):Tracker.cpp: multiple definition of `Tracker::check_word
s(char*)'
Main.exe(.text+0x47d8):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:225: first defined here
Tracker.o(.text+0x946):Tracker.cpp: multiple definition of `Tracker::getInt()'
Main.exe(.text+0x3fbe):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:157: first defined here
Tracker.o(.text+0xa08):Tracker.cpp: multiple definition of `Tracker::getLong()'
Main.exe(.text+0x4080):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:169: first defined here
Tracker.o(.text+0x164c):Tracker.cpp: multiple definition of `Tracker::announce_l
ist_list_end()'
Main.exe(.text+0x4cc4):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:307: first defined here
Tracker.o(.text+0x15f6):Tracker.cpp: multiple definition of `Tracker::do_announc
e_list_next_announce(char*, int)'
Main.exe(.text+0x4c6e):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:300: first defined here
Tracker.o(.text+0x1f42):Tracker.cpp: multiple definition of `Tracker::do_info_fi
les_next_path(char*, int)'
Main.exe(.text+0x55ba):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:431: first defined here
Tracker.o(.text+0x225c):Tracker.cpp: multiple definition of `Tracker::lcase(char
*)'
Main.exe(.text+0x58d4):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:485: first defined here
Tracker.o(.text+0x14e0):Tracker.cpp: multiple definition of `Tracker::do_announc
e()'
Main.exe(.text+0x4b58):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:282: first defined here
Tracker.o(.text+0x154c):Tracker.cpp: multiple definition of `Tracker::do_announc
e_list()'
Main.exe(.text+0x4bc4):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:290: first defined here
Tracker.o(.text+0x16f8):Tracker.cpp: multiple definition of `Tracker::do_creatio
n_date()'
Main.exe(.text+0x4d70):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:319: first defined here
Tracker.o(.text+0x177a):Tracker.cpp: multiple definition of `Tracker::do_comment
()'
Main.exe(.text+0x4df2):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:324: first defined here
Tracker.o(.text+0x17e4):Tracker.cpp: multiple definition of `Tracker::do_created
_by()'
Main.exe(.text+0x4e5c):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:331: first defined here
Tracker.o(.text+0x184e):Tracker.cpp: multiple definition of `Tracker::do_info()'

Main.exe(.text+0x4ec6):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:338: first defined here
Tracker.o(.text+0x2048):Tracker.cpp: multiple definition of `Tracker::discard()'

Main.exe(.text+0x56c0):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:442: first defined here
Tracker.o(.text+0x1a36):Tracker.cpp: multiple definition of `Tracker::do_info_le
ngth()'
Main.exe(.text+0x50ae):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:376: first defined here
Tracker.o(.text+0x1b10):Tracker.cpp: multiple definition of `Tracker::do_info_na
me()'
Main.exe(.text+0x5188):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:386: first defined here
Tracker.o(.text+0x1b7a):Tracker.cpp: multiple definition of `Tracker::do_info_pi
ece_length()'
Main.exe(.text+0x51f2):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:393: first defined here
Tracker.o(.text+0x1bfc):Tracker.cpp: multiple definition of `Tracker::do_info_pi
eces()'
Main.exe(.text+0x5274):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:398: first defined here
Tracker.o(.text+0x1c8e):Tracker.cpp: multiple definition of `Tracker::do_info_fi
les()'
Main.exe(.text+0x5306):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:406: first defined here
Tracker.o(.text+0x1dac):Tracker.cpp: multiple definition of `Tracker::do_info_fi
les_length()'
Main.exe(.text+0x5424):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:414: first defined here
Tracker.o(.text+0x1e38):Tracker.cpp: multiple definition of `Tracker::do_info_fi
les_path()'
Main.exe(.text+0x54b0):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:419: first defined here
Tracker.o(.text+0x234c):Tracker.cpp: multiple definition of `Tracker::printTrack
er()'
Main.exe(.text+0x59c4):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Trac
ker.cpp:493: first defined here
Hash.o(.text+0x104):Hash.cpp: multiple definition of `rotl(unsigned int, int)'
Main.exe(.text+0x5dcc):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Hash
.cpp:15: first defined here
Hash.o(.text+0x13e):Hash.cpp: multiple definition of `hash(char*, int)'
Main.exe(.text+0x5e06):c:/Documents and Settings/Bas/Bureaublad/Project/2-1/Hash
.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 this post


Link to post
Share on other sites
Advertisement
-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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!