Jump to content
  • Advertisement
Sign in to follow this  
dolphins87

Cant figure out error message?

This topic is 4083 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im doing some of the excerises in Thinking in C++ 2nd Edition Volume One and I am trying to complie one of the examples but i keep getting these errors? c:\program files\microsoft visual studio 8\vc\include\sal.h(226) : error C2143: syntax error : missing ';' before 'string' c:\program files\microsoft visual studio 8\vc\include\sal.h(226) : error C2059: syntax error : 'string' c:\program files\microsoft visual studio 8\vc\include\sal.h(226) : error C2143: syntax error : missing ';' before '{' c:\program files\microsoft visual studio 8\vc\include\sal.h(226) : error C2447: '{' : missing function header (old-style formal list?) this is the code I have right now its very simple but I dont know whats going on
//: C04:CppLib.h
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
// C-like library converted to C++


struct Stash {
  int size;      // Size of each space
  int quantity;  // Number of storage spaces
  int next;      // Next empty space
   // Dynamically allocated array of bytes:
  unsigned char* storage;
  // Functions!
  void initialize(int size);
  void cleanup();
  int add(const void* element);
  void* fetch(int index);
  int count();
  void inflate(int increase);
}; ///:~


and
#include "Clib.h"
#include "CppLib.h"
#include <iostream>
using namespace std;

struct A
{
	int i[100];
};

struct B
{
	void f();
};

void B::f() { }

int main()
{
	cout << "sizeof structA = " << sizeof(A)
		 << " bytes"  << endl;
	cout << "sizeof structB = " << sizeof(B)
		 << " bytes" << endl;
	cout << "sizeof CStash in C = " 
		 << sizeof(CStash) << " bytes" << endl;
	cout << "sizeof Stash in C++ = " 
		 << sizeof(Stash) << " bytes" << endl;
}


I understand what the excerise is doing but I cant figure out where my errors are coming from beacuse when I click on the errors it just keeps brining up "sal.h" and I'm a little knew to progamming and Ive been through the book Learn C++ in 24 hours but I want to get a better grasp of the language before moving on to game progamming but any help would be appericated. Thanks

Share this post


Link to post
Share on other sites
Advertisement
heres Clib.h as well


// header file for a C-like libary
// An array-like entity created at runtime

typedef struct CStashTag
{
int size; // size of each space
int quantity; // number of storage spaces
int next; // next empty space
// dynamically allocated array of bytes
unsigned char* storage;
} CStash;

void initialize(CStash *s, int size);
void cleanup(CStash *s);
int add(CStash* s, const void* element);
void *fetch(CStash *s,int index);
int count(CStash *s);
void inflate(CStash *s, int increase);

Share this post


Link to post
Share on other sites
Did you:
(1) Build your project as a "Windows Console Application"?
(2) Disable precompiled headers?

Share this post


Link to post
Share on other sites
yes I set up a windows console application and ive disabled the precomplied headers and I dont know if this helps but im using Visual C++ 2005 Express Edition

Share this post


Link to post
Share on other sites
There's probably a subtle error in one of your files...

Break it down to the basics - remove everything from your .cpp except "int main(){}" and make sure it compiles fine. Then start adding things one at a time to see where the problem is.

Share this post


Link to post
Share on other sites
Hmm, you should not be getting errors in sal.h! In Visual Studio, right click on your .cpp file in Solution Explorer (it is a .cpp file not a .c file right?) and go to Properties. You'll need to find the option "Compile As..." which I think is in Compiler -> Advanced. Make sure it is set to compile as C++, not compile as C. (Or heck, if that doesn't fix it try it the other way around!) That's my best guess, though I'd be amazed if SAL wasn't set to work correctly regardless of which it was compiled into...

Share this post


Link to post
Share on other sites
Also, make sure your files end with a new-line, otherwise that last line of CppLib.h
///:~
might be prepended to iostream.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!