Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

C/C++ very simple question.

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
uman
Apprentice
Apprentice
Posts: 223
Joined: Mon Dec 20, 2004 8:00 pm

C/C++ very simple question.

  • Quote

Post by uman » Sun Feb 06, 2005 2:00 am

My question is this: let's say I have a file called "foobar.h" and another file called "quux.h", and they both rely on each other. If I #include foobar.h in quux.h and #include "quux.h" in foobar.h, there is obviously an infinite loop. How can I get around this?
Top
paulbiz
Guru
Guru
Posts: 508
Joined: Sun Feb 01, 2004 9:03 pm
Location: St. Louis, Missouri, USA

  • Quote

Post by paulbiz » Sun Feb 06, 2005 2:03 am

encapsulate your entire foobar.h file in an #ifndef foobar_h and then define something like #define foobar_h

this way if foobar_h is defined, it means it's already been loaded and you skip it's contents.
Top
uman
Apprentice
Apprentice
Posts: 223
Joined: Mon Dec 20, 2004 8:00 pm

  • Quote

Post by uman » Sun Feb 06, 2005 3:20 am

thanks for the help.
Top
vdboor
Guru
Guru
User avatar
Posts: 592
Joined: Wed Dec 03, 2003 9:31 am
Location: The Netherlands
Contact:
Contact vdboor
Website

  • Quote

Post by vdboor » Sun Feb 06, 2005 12:05 pm

Can you pre-declare certain symbols?

like:

Code: Select all

class Foo;

class Quux
{
  private:
    Foo * foo;
}
And only include "foo.h" in "quux.cpp". It's also compiles the project much faster.
The best way to accelerate a windows server is by 9.81M/S²
Linux user #311670 and Yet Another Perl Programmer

[ screenies | Coding on KMess ]
Top
Post Reply

4 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic