Creating header files

This is a discussion on Creating header files within the C++ Programming forums, part of the General Programming Boards category; As part of one of my projects, I have to create a program that doesn't use any header files except ...

Creating header files

As part of one of my projects, I have to create a program that doesn't use any header files except ones that I created myself. Even cout and cin is out. i have looked through a few of the header files that came with my compiler and can't understand a single thing in them. Does any body know where I can learn to write (or at least read) a header file.

This is rather a bad thing to do. Do NOT try to just manually include pieces of header files. Most are written in compiler and system specific methods, that if used in the wrong way, will result in undefined behavior.

And I'm telling you now, you're so way out of your depth that you can't even see the bottom. Learn the actual language first. Your questions so far show that you are struggling with the basics of C++, yet you want to one of the most complicated things you can do as a programmer for a learning project.

I say, forget it. Write normal programs in a nice, hosted environment, until you actually know the language. What you're doing right now is pointless.
When you actually know the language, then you can return to your OS ambitions. But before that, you also need to learn a lot about computer architecture and related topics.

Again: the OP wants to create an operating system. The restriction on not using any system headers comes not from braindead exercise limitations, but from the simple fact that his own OS wouldn't have these headers unless he implemented them first.

There is no point in not using someone elses header files, if you don't also implement the functionality needed in some other way. Say for example we can't use stdio.h: Ok, so we can't do printf/scanf - but we could of course write a more or less complete other implementation of printf/scanf to use in our application, and the related header-file(s) to cope with that.

But there's no magic involved - the original poster appears to think that header files are "magic" in some way. They are not.

This is used to communicate common information between the calling and called functions. For example, in the Linux system call open("somename.txt", O_RDONLY), we need a O_RDONLY to be defined in the same way in both the calling code and the function definition of open - strange behaviour would happen if O_RDONLY is 3 in one place and 6 in the other.

Now, the original poster obviously needs to come up with a set of functionality that the OS should support, split it into nice little chunks (e.g. file I/O, interprocess communication, time management, driver functions etc) and decide what data structures & types are needed, constants and what functions are needed to support this functionality. The implement that as a set of header files and a set of functions to actually perform the operation.