Public Group

Cant figure out error message?

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

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
// 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();
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 on other sites
it looks like you posted CppLib.h... post CLib.h as well.

Share on other sites
heres Clib.h as well

// header file for a C-like libary// An array-like entity created at runtimetypedef 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 on other sites
Did you:
(1) Build your project as a "Windows Console Application"?

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 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 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 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.

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633654
• Total Posts
3013169
×