Skip to main content
gamedev.net
🔒 Locked

SRGP / g++ problem.

Started by MDI Sep 27, 2006 at 2:28 PM 1 replies 1.9k views
Original Post
MDI
MDI
Hi, I'm using SRGP for a class project on Linux. using g++ (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1). Whenever I try to include the SRGP header into my source file, I get the following strange error: /usr/include/unistd.h:418: error: expected primary-expression before ‘__useconds’ /usr/include/unistd.h:418: error: expected `)' before ‘__useconds’ I'm compiling my project with the command: g++ -fpcc-struct-return -I/usr/include/srgp -O2 *.cpp -L/usr/X11R6/lib -lsrgp -lX11 -lm -o cg Whenever I remove the #include command, the error goes away and the project compiles fine. Has anyone ever had this problem (I'm working on a FC5 machine, if that matters)? The relevant source file is only small. I've tried it with and without the extern "C", aswell as changing the order of the stdio and stdlib includes (the example my lecturer gave of using SRGP had those included):

// FIXME: weird bug here, unistd.h
#include <stdio.h>
#include <stdlib.h>

extern "C" { 
	#include <srgp.h>
}

#include "Window.h"
#include "Canvas.h"

namespace ComputerGraphics
{
	Window::Window()
	{
	}

	// Create a new window and return a canvas for painting onto it.
	ICanvas* Window::create(const std::string& title,
							int width, int height)
	{
		SRGP_begin(const_cast<char*>(title.c_str()), width, height, 8, 1);
		return new Canvas(width, height, WHITE);
	}

	// Destroy the window.
	void Window::destroy(ICanvas* canvas)
	{
		delete canvas;
		canvas = 0;
		SRGP_end();
	}
}

Thanks, MDI.
Bregma
Bregma
The symptom you describe has all the hallmarks of a C-preprocessor MACRO problem.

A quick glance at shows that there's probably a macro with the name "usleep" (although it could be "ualarm" or "__useconds_t") somewhere. Alternatively, there could be a header file with the name "stddef.h" somewhere hiding the system header .

Given that , , and all come from the same source (in your case, glibc), the problem is either in or in your code. A quick check of the preprocessed files (add the -save-temps arg to the gcc command line) and a recursive grep of the SRGP and your project headers might reveal the true cause.
Stephen M. Webb
Professional Free Software Developer

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.