Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-20-2006, 10:05 PM   #1
Registered: Oct 2003
Distribution: Ubuntu 7.04
Posts: 889
Blog Entries: 1

Rep: Reputation: 30
howto allow strings in header (.h) files?

I recently attempted to include prototypes of some of my files into my header file, but on "make", I recieved the following:

[georig1\ 18:52:50\ george\ ~/cfiles/George Lair/050606]$ make
g++ -c `sdl-config --cflags` main.cpp
In file included from main.cpp:9:
headerfiles.h:44: error: expected constructor, destructor, or type conversion before '*' token
headerfiles.h:44: error: expected `,' or `;' before '*' token
headerfiles.h:45: error: variable or field `WrightIn' declared void
headerfiles.h:45: error: `string' was not declared in this scope
make: *** [main.o] Error 1
[georig1\ 18:56:06\ george\ ~/cfiles/George Lair/050606]$
I googled string and makefile(s) and different phrasings of my problem, then just Makefiles and read a couple makefile tutorials, but so far I haven't come across anything showing that I can or can't have prototypes of string functions. So my question is, how do I have my string functions play nicely with my headerfile?

Here is the actual file:


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <SDL/SDL.h>
#include "SDL_ttf.h"
#include <time.h>
#include <fstream>
#include <string>

void FightChk();
void display_bmp(char *file_name, int x2, int y2);
void display_font(int x2, int y2, int Psize, int R, int G, int B);
void move_xy(bool x, bool y);
string * ReadOut(void); // This operates in conjunction with ReadFilesLines()
void WrightIn(string STRING); // This operates alone.
void ReadFileLines(void); // This operates in conjuction with ReadOut()
	extern SDL_Surface *text_surface, *image, *screen;;
	extern bool done;
	extern SDL_Rect dest;

using namespace std;
Old 05-20-2006, 10:07 PM   #2
Registered: Oct 2003
Distribution: Ubuntu 7.04
Posts: 889
Blog Entries: 1

Original Poster
Rep: Reputation: 30
OOPS! Problem fixed, I should have put "using namespace std;" before all the prototype declarations!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
group files by strings in dir Melsync Programming 7 12-17-2005 01:53 PM
Including header files and source files for classes Feenix Programming 8 09-28-2005 11:53 AM
c header files in linux in place of header files in windows? harun_acs Programming 1 03-17-2004 03:24 AM
Searching files for strings tmoorman Linux - Software 4 01-08-2004 02:46 PM
concatenating strings to open files veilig Programming 1 11-10-2003 06:36 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration