I would like to include a library - to do so I need to convert some stuff in the .h file to a .inc (from my understanding). Is there any documentation or method I can find on doing this?

I'm using NASM
Posted on 2010-04-23 10:48:07 by Brainiac
Have you ever opened a .h file? You can open it in a text editor. It's not a magically encrypted "stuff". Then, you can just manually rewrite it. But I believe there already are good include files for NASM.
Posted on 2010-04-23 11:57:52 by ti_mo_n
Apologies, I probably wasn't clear enough on what I meant -- what exactly *IS* the .inc format? I know it is used to include a library, I know it's used with the linker or assembler, and I'm thinking it's much like the .h file -- but what's the difference? Clearly, if I just renamed a .h file to .inc they would be incompatible.

For example, suppose I had a library - we'll just call it Library X. It could be any C library, a graphics library - sdl, allegro, a library you yourself write, etc. How could a inc file be made? Where is the labels for .inc documented?

One quick example of a label is IMPORT, see x.inc in the linux NASMX project to see it used to import functions. But what is it, where can I look it up, etc.

Thanks ahead of time, I know it's kind of a tedious question.  :)
Posted on 2010-04-23 13:11:17 by Brainiac
.h (or inc) aren't used by linkers. They are used by compilers/assemblers . And they are the same thing, functionally. They differ only in syntax. But, as I said, every relevant inc file should have already be written. And they usually have same names. So if you have an .h file, try gogling for an .inc file with teh same name - you'll most likely find one.

Hs/INCs are not libraries - they hold contant definitions, structure definitions, macros, function declarations, etc.
Posted on 2010-04-23 15:23:30 by ti_mo_n
The only difference between .h and .c, or .inc and .asm, is the file extension. Everything inside is the same: plain-text source code specific to a language/assembler/compiler.

File extensions are only for the convenience of logical organization. When you see a .h file, you know it's a header file (source code that can be included by multiple .c/cpp files) without having to peak inside.

That being said, in assembly language some people prefer to use .inc files for the same reasons that .h files are used in C/C++.

As for IMPORT in NASMX, nasmx.inc contains this particular macro.
Posted on 2010-04-23 16:53:27 by SpooK
Hi Brainiac,

Are you the same guy that just asked this (similar) question on the !Yahoo! linux-nasm-users list? Well, no matter, same answer... Johannes Kroll's "h2incn" will convert from .h (C syntax) to .inc (Nasm syntax). (as you point out, they are not compatible - dunno why Nasm doesn't support "#define", but it doesn't...)

http://home.comcast.net/~fbkotler/h2incn-0.5.tar.gz

As to "all the .inc files have been written"... maybe in the Windows world (I doubt even that!)...

If there's a particular library that's causing you trouble... "Bring it on!" :)

Best,
Frank

Posted on 2010-04-23 19:40:27 by fbkotler
Heh, yep that's me. Your the same guy that answered to! I'd heard the phrase "It's a small world", but I didn't realise it applied to the Internet!  :shock:

Thanks for all the answers. It makes more sense to me now, especially since ti_mo_n mentioned the assembler handling ".inc" files.  I think the fact that I didn't see .inc listed in the NASM docs had me confused as to what it was. I guess I was under the impression it was something standard with assemblers or something. But nonetheless, I've re-checked the NASM documentation and I get it now. :)
Posted on 2010-04-23 20:47:21 by Brainiac