compiling with SDL issues

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: compiling with SDL issues

Post by eatcomics »

GyroVorbis wrote:
eatcomics wrote:Don't include headers in headers, they're bad...
You do realize that while it is definitely good practice to keep header includes from headers to a minimal, simple class/function prototyping often isn't enough? Consider class A inheriting from class B. Class A REQUIRES Class B to be included, so that the compiler knows how much space to allocate in memory for an instance of class A.
I actually don't prototype classes, just functions. I have no idea why I put that, must not have been paying enough attention
Image
Live-Dimension
Chaos Rift Junior
Chaos Rift Junior
Posts: 345
Joined: Tue Jan 12, 2010 7:23 pm
Favorite Gaming Platforms: PC - Windows 7
Programming Language of Choice: c++;haxe
Contact:

Re: compiling with SDL issues

Post by Live-Dimension »

X Abstract X wrote:
GyroVorbis wrote:
X Abstract X wrote: A header file should be able to compile with it's cpp file left empty.
A header file has absolutely no dependence on a .cpp file whatsoever (unless you're #including a .cpp from within the header). This doesn't make any sense.
What I meant was that something like the following would not compile until you include <string> in the .cpp file (and it would have to be included before including "A.h"). Which is why you should include <string> inside the header instead, unless you can get away with a forward declaration instead. Am I wrong about this?

A.h

Code: Select all

#ifndef A_H
#define A_H

class A {
public:
    void doShit(const std::string& myString);
};

#endif
A.cpp

Code: Select all

#include "A.h"
That's perfectly fine and valid. =]
Image
Post Reply