Author Topic: Statement not recognized (or not correctly)  (Read 3437 times)

Offline devinp52

  • Single posting newcomer
  • *
  • Posts: 2
Statement not recognized (or not correctly)
« on: April 19, 2011, 04:04:26 am »
Hi, I'm a somewhat new used to code::blocks, and I just have a question regarding a compilation error I'm getting.  I'm compiling using the MS Visual C++ 2005/2008 compiler (hence the pragmas) and I'm getting an error when I use:

Code
#if PLATFORM == PLATFORM_WINDOWS

void wait( float seconds )
{
Sleep( (int) ( seconds * 1000.0f ) );
}

#else

#include <unistd.h>
void wait( float seconds ) { usleep( (int) ( seconds * 1000000.0f ) ); }

#endif

and the error I'm getting is that there are multiple definitions of the method wait.  Obviously (maybe not?) it sees both of those statements and automatically thinks they are duplicates.

For a little more info, this is a sample code for learning to use sockets and some basic networking protocols. The project is http://www.gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/ and it's listed in a link under example program.  Thanks in advance for the help!  It's probably an easy fix :)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Statement not recognized (or not correctly)
« Reply #1 on: April 19, 2011, 04:54:20 am »
This error is Not related to C::B.
So, I think the best place to ask is: MSVC mail list/newsgroups. or other programming forum.

If you think it is C::B related, you should at least show the full build log message and other infos.

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.