Advertisement

FLTK -- error C2059: syntax error : 'string'

Started by September 30, 2004 01:51 PM
7 comments, last by OpenGL_Guru 20 years, 2 months ago
i am trying to write a file chooser GUI for popping up a file dialog from then which i can browse the local contents of files and directories on the local machine. the only GUI that i have to do this in any intuitive manner is FLTK but the instantiation of the class from which the file chooser is derived from as the documentation states is either confusing or my brain is fried from programming too much today... http://fltk.org/documentation.php/doc-1.1/Fl_File_Chooser.html#Fl_File_Chooser here is the link to the class description and what parameters it wants as follows and i quote: Fl_File_Chooser(const char *pathname, const char *pattern, int type, const char *title) i have the correct header included and my code to make a pop up window is : Fl_File_Chooser *fl_file_chooser("testing", "*.jpg", "title"); it keeps giving me the error in the heading of the thread and on msdn it told me very little only mentioned something about external C. since i am not a C programmer or never have been i guess i dont understand this part. could anyone help in diagnosing this compiler error? any more information i will gladly give...maybe some of you have also worked with FLTK. thanks!
heh
are you:

#include <string>

at the top of your file? are you then making string variable declarations thusly:

std::string foo;

i.e. std:: needs to precede string wherever you use it as a type name.

-me
Advertisement
well i included string.h... ive done other strings with FLTK with other stuff and i have never got this error. so again yes this is at the top of the file.
heh
post the code surrounding the line in question.

-me
sorry to do this but i am going to give you the whole cpp file so you can see the different calls and widgets etc that i have made..

#include <windows.h>
#include <iostream.h>
#include <string.h>

//#include <../fltk-1.1.4-source/fltk-1.1.4/FL/Fl.H>
//#include <../fltk-1.1.4-source/fltk-1.1.4/FL/Fl_Window.H>
//#include <../fltk-1.1.4-source/fltk-1.1.4/FL/Fl_Box.H>

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Light_Button.H>
#include <FL/Fl_Round_Button.H>
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Return_Button.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_File_Input.H>
#include <FL/Fl_Scrollbar.H>
#include <FL/Fl_File_Browser.H>
#include <FL/filename.H>
#include <FL/Fl_File_Chooser.H>



Fl_Round_Button *rbutton;

void change_status(Fl_Widget *w)
{

cout << "status changed....." ;
(rbutton->value() == 1) ? cout << "radio is on:" << endl : cout << "radio is off: " << endl;

}

int main(int argc, char **argv)
{
//char ch;

Fl_Window *window = new Fl_Window(800,600);
//window->color(FL_CYAN);
Fl_Box *box = new Fl_Box(20,20,100,100,"testing 1-2-3");
box->box(FL_UP_BOX);
box->labelsize(10);
box->labelfont(FL_ITALIC);
box->labeltype(FL_SHADOW_LABEL);

Fl_Button *button = new Fl_Button(20, 150, 50, 50, "Button");
//button->color(FL_BLUE);
Fl_Light_Button *lbutton = new Fl_Light_Button(20, 300, 20, 20, " lightbox");
lbutton->selection_color(FL_BLACK);
rbutton = new Fl_Round_Button(20, 400, 20, 20, "radio");
rbutton->selection_color(FL_RED);

Fl_Input *input = new Fl_Input(200, 410, 200, 20, "input text");
//input->value("Now is the time for all good men...");

Fl_File_Input *inputF = new Fl_File_Input(550, 400, 200, 35, "Filename Browse");
//input->value("Now is the time for all good men...");

Fl_Button *check_button = new Fl_Check_Button(20, 500, 20, 20, "checkbox");
Fl_Button *return_button = new Fl_Return_Button(20, 550, 350, 50, "return button");

Fl_Scrollbar *vscroll = new Fl_Scrollbar(200, 300, 15, 100, "vertical scrollbar");

Fl_Scrollbar *hscroll = new Fl_Scrollbar(300, 300, 100, 15, "horizontal scrollbar");
hscroll->type(FL_HORIZONTAL);

-->>where error occurs
Fl_File_Chooser *fl_file_chooser("testing", "*.jpg", "title");
rbutton->callback(change_status);

window->end();
window->show(argc, argv);
return Fl::run();
}
heh
that doesn't really help. where _specifically_ does the compiler say the error is? is it in the headers or is it in your own code? either way, post the _exact_ line of code where the error is.

[edit: nmind just found in your code where you put "error is here" :)]

-me
Advertisement
Compiling...
fltk_basics.cpp
c:\program files\microsoft visual studio\vc98\myprojects\fltk_basics\fltk_basics.cpp(70) : error C2059: syntax error : 'string'
Error executing cl.exe.

fltk_basics.exe - 1 error(s), 0 warning(s)

it points in my main.cpp(named fltk_basics.cpp) to the line number where the code in question is. so it points to my code, not any headers..
heh
There seem to be two errors. The first is that you're only passing three parameters when you should be passing four - you're giving string, string, string, when you should be giving string, string, int, string.

The second is that you seem to be declaring a pointer and initialising it as an object.

Enigma
thanks Enigma.. its working now.. i fixed the problem this morning b4 i even checked this thread.. guess i needed to rest my eyes a bit and get a different viewpoint about it..thanks again! now i just have to get FLTK to work with openGL ;)
heh

This topic is closed to new replies.

Advertisement