Error Msg

This is a discussion on Error Msg within the C++ Programming forums, part of the General Programming Boards category; I have been going through the search and I am still stuck...I keep getting "cannot create pre-compiled header: code in ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    94

    Unhappy Error Msg

    I have been going through the search and I am still stuck...I keep getting "cannot create pre-compiled header: code in header"


    I read that it means as it says but I dont know what to do about it. Someone pls, pls tell me how I go about getting rid of this error. I have 4 .h files and 2 .cpp files.
    Code:
    .h files and their includes
    
    bstree -> #include "btnode.h"
    dictionary -> #include "btnode.h"
                      #include "bstree.h"
                      #include "mystring.h"
    
    .cpp files and their includes
    
    main -> #include "dictionary.h"
    dictionary - > #include "dictionary.h"
    NB:
    I am using borland.

    Thanx
    simple is always an understatement.....

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,437
    > cannot create pre-compiled header: code in header
    It means you have code inside the header file

    Code:
    void foo ( void ) {
      cout << "hello";
    }
    What you should have in the header is only
    void foo ( void );

    And put the actual code in a .cpp file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    94
    I do...but they are templates. This has not caused any problems before.
    simple is always an understatement.....

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    If Borland doesn't support templates in precompiled headers then you either have to stop using precompiled headers or stop using Borland, as I don't think you want to stop using templates.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    94
    I dont get what a precompiled header is Maybe someone could tell me, so as I might be able to try and solve this problem.
    simple is always an understatement.....

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21