Hi,
im working on a program which has to process data coming through the serial port then create an interface with SDL.I did 1 program to receive the data n process them n another program for the interface using sdl.They both work perfectly.Im started having problems when i wanted to merge the two programs.Here is a simplified version of the merged program n the errors.Thanks in advance.Im trying to fix this problem for about a week but cant.

Code:
#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#pragma comment(lib, "SDL_image.lib")
#endif

#include <windows.h>
#include <stdlib.h>
#include "SDL/SDL.h"
#include "SDL_Image.h"

#define TRUE 1
#define FALSE 0


#define RX_SIZE         4096    /* taille tampon d'entree  */
#define TX_SIZE         4096    /* taille tampon de sortie */
#define MAX_WAIT_READ   5000    /* temps max d'attente pour lecture (en ms) */



/* Handle du port COM ouvert */
HANDLE g_hCOM = NULL;

/* Delais d'attente sur le port COM */
COMMTIMEOUTS g_cto =
{
    MAX_WAIT_READ,  /* ReadIntervalTimeOut          */
    0,              /* ReadTotalTimeOutMultiplier   */
    MAX_WAIT_READ,  /* ReadTotalTimeOutConstant     */
    0,              /* WriteTotalTimeOutMultiplier  */
    0               /* WriteTotalTimeOutConstant    */
};

/* Configuration du port COM */
DCB g_dcb =
{
    sizeof(DCB),        /* DCBlength            */
    57600,               /* BaudRate             */
    TRUE,               /* fBinary              */
    FALSE,              /* fParity              */
    FALSE,              /* fOutxCtsFlow         */
    FALSE,              /* fOutxDsrFlow         */
    DTR_CONTROL_ENABLE, /* fDtrControl          */
    FALSE,              /* fDsrSensitivity      */
    FALSE,              /* fTXContinueOnXoff    */
    FALSE,              /* fOutX                */
    FALSE,              /* fInX                 */
    FALSE,              /* fErrorChar           */
    FALSE,              /* fNull                */
    RTS_CONTROL_ENABLE, /* fRtsControl          */
    FALSE,              /* fAbortOnError        */
    0,                  /* fDummy2              */
    0,                  /* wReserved            */
    0x100,              /* XonLim               */
    0x100,              /* XoffLim              */
    8,                  /* ByteSize             */
    NOPARITY,           /* Parity               */
    ONESTOPBIT,         /* StopBits             */
    0x11,               /* XonChar              */
    0x13,               /* XoffChar             */
    '?',                /* ErrorChar            */
    0x1A,               /* EofChar              */
    0x10                /* EvtChar              */
};

/*=============================================================================
  Fonctions du module.
=============================================================================*/
BOOL OpenCOM    (int nId);
BOOL CloseCOM   ();
BOOL ReadCOM    (void* buffer, int nBytesToRead, int* pBytesRead);
void extract (unsigned char buffer[], unsigned char skinf[], unsigned char eyef[]);
int condata(unsigned char a,unsigned char b);
float Lux(unsigned char taosch0,unsigned char taosch1);
int tempconv(uint16_t TempData);

int main(int argc, char *argv[])
{
	SDL_Surface *screen;
	SDL_Surface *picture;
	SDL_Event event;
	SDL_Rect pictureLocation;	
	const SDL_VideoInfo* videoinfo;
	
	atexit(SDL_Quit);
	
	
	/* Initialize the SDL library */
	if( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
		fprintf(stderr,
			"Couldn't initialize SDL: %s\n", SDL_GetError());
		exit(1);
	}

	screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF | SDL_HWSURFACE);
	if ( screen == NULL ) {
		fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
			SDL_GetError());
		exit(1);
	}

	videoinfo = SDL_GetVideoInfo();

	printf("%i", videoinfo->blit_hw);

	// Load Picture
	picture = IMG_Load("smiley2.bmp");

	if (picture == NULL) {
		fprintf(stderr, "Couldn't load %s: %s\n", "SDL_now.bmp", SDL_GetError());
		return 0;
	}

	pictureLocation.x = 210;
	pictureLocation.y = 100;
	
	while(1) {
		
		SDL_FillRect(screen, NULL, 1000);
		SDL_BlitSurface(picture, NULL, screen, &pictureLocation);
		SDL_Flip(screen);

	}

	return 0;
}
http://forums.futura-sciences.com/me...045-errors.jpg