Original Post
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): Thanks, MDI.
// 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();
}
}