Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: error: redefinition of new  (Read 3150 times)

0 Members and 1 Guest are viewing this topic.

greeniekin

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
error: redefinition of new
« on: December 21, 2014, 11:48:56 pm »
I am using codeblocks on windows.

i added "#include <SFML/Audio.hpp>" to a file now when I compile I get

Quote
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\new||In function 'void* operator new(std::size_t, void*)':|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\new|111|error: redefinition of 'void* operator new(std::size_t, void*)'|
..\shared\tools.h|36|error: 'void* operator new(size_t, void*)' previously defined here|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\new||In function 'void* operator new [](std::size_t, void*)':|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\new|113|error: redefinition of 'void* operator new [](std::size_t, void*)'|
..\shared\tools.h|37|error: 'void* operator new [](size_t, void*)' previously defined here|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\new||In function 'void operator delete(void*, void*)':|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\new|117|error: redefinition of 'void operator delete(void*, void*)'|
..\shared\tools.h|38|error: 'void operator delete(void*, void*)' previously defined here|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\new||In function 'void operator delete [](void*, void*)':|
c:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\new|118|error: redefinition of 'void operator delete [](void*, void*)'|
..\shared\tools.h|39|error: 'void operator delete [](void*, void*)' previously defined here|
||=== Build finished: 8 errors, 0 warnings (0 minutes, 2 seconds) ===|

I tried including System instead and same errors the errors do not make sense to me. Soon as I remove the include everything is fine.

Edit:
here is the tools.h file http://websvn.tuxfamily.org/filedetails.php?repname=tesseract%2Fmain&path=%2Fsrc%2Fshared%2Ftools.h
« Last Edit: December 22, 2014, 12:04:07 am by greeniekin »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: error: redefinition of new
« Reply #1 on: December 22, 2014, 12:43:15 am »
Which SFML file/package did you download?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

greeniekin

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: AW: error: redefinition of new
« Reply #2 on: December 22, 2014, 01:35:43 am »
I downloaded SFML2.2 from the all source code on the download page and built it my self.

Though it seems unrelated from linking as I removed the link to sfml and I still get the same error.


It seems to be this section of code in tools.h that is being a hassle
Quote
inline void *operator new(size_t, void *p) { return p; }
inline void *operator new[](size_t, void *p) { return p; }
inline void operator delete(void *, void *) {}
inline void operator delete[](void *, void *) {}

While it might seem obvious this is the problem it is not as when I remove the SFML include it all builds fine.
Deleting this section of code is not really an option either as then the rest of the code will not build.


Edit:
Never mind I worked it out.
The code snipet above was implementing a "placement new".

There is also an include for placement new which can be included by "#include <new> "

presumably SFML calls this somewhere and that is why it is redeclared.
I just deleted the above snipet and put a "#include <new>" there instead
« Last Edit: December 22, 2014, 03:14:29 am by greeniekin »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: error: redefinition of new
« Reply #3 on: December 22, 2014, 10:52:33 am »
Never had this issue with any compiler incl. the TDM 4.7.1. Thus I'm certain the error occures due to something else.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/