Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot create pre-compiled; code in header

Status
Not open for further replies.

rozzay

Programmer
Jan 3, 2002
142
US
Good morning,

I am having a problem with the error messsage "cannot create pre-compiled; code in header" the error points to the syntax below where the { starts:

#include <iostream.h>
#include "student.h"
#include <string.h>

student::student(char name[]) //constructor
{
count++; //increment count
studentID = count;
strcpy(fname, name);
}

What did i do wrong?
 
Howdy,

I get that message all the time. I can see no real pattern to it... Sometimes I open projects and Borland throws that message, then the next time it wont.

I don't know if it is a bug or what, but I wouldn't worry about it...

onrdbandit
 
As i read it the compiler complains that the "student.h" has code in it that depends upon variables external to "student.h".

I might be off target but it's what i read from that.

The very idea in making classes is that they're self-contained and thus independant of the rest of the project but they CAN of course be an integral part and use global variables and such.

Totte
 
After you finish with editing "student.h" file, put it above #pragma hdrstop directive
 
The first thing I do when creating a new project is setting the option Pre-compiled headers to None (in tab Compiler in Project options) and deleting all *.csm files. I've only troubles with it.
 
Everything is just fine with precompiled-headers! :) And it speeds-up compiling significatnly!
All you have to do is to :

- include system header files above #pragma hdrstop
- include your header files (frequently changed) below #pragma hdrstop

and it should be fine!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top