Sign in to follow this  

Noob question about headers

This topic is 2542 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have this from an example program from ClanLib, program.h :

#pragma once

// This is the Program class that is called by CL_ClanApplication
class Program
{
public:
static int main(const std::vector<CL_String> &args);
};


But I don't get it, how can this work in their project ?
In my project I should include <vector> and <ClanLib/core.h> for these, or the project won't compile...

Share this post


Link to post
Share on other sites
I'm not sure exactly where your confusion is coming in but it looks as though that static function "main" will be called by whatever the real entry point of the application is (whether that's main or winmain or whatever else).

Instead of having "int argc" and "char **argv", the entry point passes the arguments as a vector of strings.

All looks ok to me...

does this answer your question at all?

Share this post


Link to post
Share on other sites
The idea was that program.h without the #include <vector> will give an error like "'std' : is not a class or namespace name" in my project, the same for #include <ClanLib/core.h>...

How comes in their project it's ok without those includes?

Share this post


Link to post
Share on other sites
it could be that they include those files before including program.h any place they need it

that might sound like "a lot of work", but if they have precompiled headers it could be in there... or if they have an include file that contains several other include files, it could just be set up that way and they include the "main" include file, not the individual ones.



Share this post


Link to post
Share on other sites

This topic is 2542 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this