Chat Bot: Multiple headers problem

This is a discussion on Chat Bot: Multiple headers problem within the C++ Programming forums, part of the General Programming Boards category; Hey guys, im experimenting with custom header files. Problem is, i've never done this before. Below is a zip of ...

  1. #1
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

    Chat Bot: Multiple headers problem

    Hey guys, im experimenting with custom header files. Problem is, i've never done this before. Below is a zip of the .cpp and .h files, heres the error that im getting. I think it has to do with the orders i include the headers in the actual headers.

    Error:

    Compiling...
    RoDBoT.cpp
    c:\program files\microsoft visual studio\myprojects\rodbot\greet_user.h(2) : warning C4182: #include nesting level is 362 deep; possible infinite recursion
    c:\program files\microsoft visual studio\myprojects\rodbot\greet_user.h(2) : fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit
    Error executing cl.exe.

    RoDBoT.obj - 1 error(s), 1 warning(s)

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    102
    It looks like you have a cylical #include

    Do you really have to have both the files get_info.h and the greet_user.h in all the files..
    To me that seems a bit messy. What happends if you just include the file in convo.h or RoDBot.cpp??

    #include "greet_user.h"

    that is in get_info.h

    #include "get_info.h"

    that is in the greet_user.h

    That is where the cylical include error is coming in.

    I would recomend that you recode you headders so that they both do not need to includ each other.

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    at the top of each of your .h files put something like this..


    #idndef CONVO_H
    #define CONVO_H

    ..... all code here


    #endif




    do this for each .h (with different names obviously) and it will make sure each file is only included once (despite how many #include 's there are)

  4. #4
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Same error prespective:

    --------------------Configuration: RoDBoT - Win32 Debug--------------------
    Compiling...
    RoDBoT.cpp
    c:\program files\microsoft visual studio\myprojects\rodbot\greet_user.h(3) : warning C4182: #include nesting level is 362 deep; possible infinite recursion
    c:\program files\microsoft visual studio\myprojects\rodbot\greet_user.h(3) : fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit
    Error executing cl.exe.

    RoDBoT.obj - 1 error(s), 1 warning(s)

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    it worked for me; (although i had to comment out all the function code as i got some other errors and was missing some include files.) but there was no infinite recurrsion in the including

    are you putting the #endif 's after the entire file?
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with multiple files
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 03-02-2002, 08:48 AM
  2. C++ multiple inheritance problem
    By pongsor in forum C++ Programming
    Replies: 7
    Last Post: 02-08-2002, 07:18 PM
  3. Keyboard INT 9 handler (Handles multiple keypresses!) Problem
    By zhopon in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 12-16-2001, 09:39 AM
  4. Replies: 0
    Last Post: 12-16-2001, 09:36 AM
  5. Multiple Knapsack Problem
    By polymeta in forum C Programming
    Replies: 3
    Last Post: 11-15-2001, 07:03 PM

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