NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: jsvcycling on July 05, 2011, 03:00:54 AM

Title: Including C headers in NASM
Post by: jsvcycling on July 05, 2011, 03:00:54 AM
I'd like to know if it is possible to include C headers in NASM source files. I know you can use EXTERN to reference C functions, but is it possible to include C headers (similar to GAS)?

If not, I'd like to recommend that as a feature for future releases...

Thanks,
Jsvcycling
Title: Re: Including C headers in NASM
Post by: Frank Kotler on July 05, 2011, 04:58:36 AM
Rob Neff is working on something that will convert a C header into an .inc file suitable for Nasm:

http://h2incn.svn.sourceforge.net/viewvc/h2incn/trunk/

I don't anticipate the ability to eat .h files to be incorporated into Nasm, but it's an interesting idea...

Best,
Frank

Title: Re: Including C headers in NASM
Post by: Cyrill Gorcunov on July 05, 2011, 06:49:25 AM
I don't anticipate the ability to eat .h files to be incorporated into Nasm, but it's an interesting idea...

I guess we might pick it up into contrib/ directory or something like that.
Title: Re: Including C headers in NASM
Post by: jsvcycling on July 05, 2011, 02:36:57 PM
I guess we might pick it up into contrib/ directory or something like that.

Sounds like a good idea if it won't be implemented anytime soon, I can't help you very much because I'm still a NASM N00B...

http://h2incn.svn.sourceforge.net/viewvc/h2incn/trunk/

Thanks, I'll check it out...

Thanks,
Jsvcycling
Title: Re: Including C headers in NASM
Post by: Cyrill Gorcunov on July 05, 2011, 09:37:51 PM
C preprocessor parser is not hard thing (nasm preprocessor is a way more powerful) so I suspect we might consider implementing some converter inside nasm code directly as only time permits ;)
Title: Re: Including C headers in NASM
Post by: Rob Neff on July 06, 2011, 12:02:17 AM
my version of h2incn on sf.net remains incomplete.  I will revisit that project once NASMX v1.0 is out of beta ( Real Soon NowTM).

Cyril, I'm not sure if adding that capability to Nasm would be worth your effort, especially in light of what most Windows Nasm users would want it to do - pull in the entire Windows headers fileset - needed due to the many dependencies among the various files.  However, don't let me stop you if you feel it worthwhile!  ;D
Title: Re: Including C headers in NASM
Post by: Cyrill Gorcunov on July 06, 2011, 05:35:26 AM
my version of h2incn on sf.net remains incomplete.  I will revisit that project once NASMX v1.0 is out of beta ( Real Soon NowTM).

Cyril, I'm not sure if adding that capability to Nasm would be worth your effort, especially in light of what most Windows Nasm users would want it to do - pull in the entire Windows headers fileset - needed due to the many dependencies among the various files.  However, don't let me stop you if you feel it worthwhile!  ;D

OK, I see ;) I meant not only Windows users but imagine an abstract user who mixing C and asm code, in most cases there will be shared #define/%define :)
Title: Re: Including C headers in NASM
Post by: Rob Neff on July 06, 2011, 11:06:51 AM
In addition to #define are you also thinking about supporting typedef and struct { };  ???
And since we're talking about enhancing Nasm - can you please add support of nested structs/unions.
My original forum post (http://forum.nasm.us/index.php?topic=872.0) asking for that feature.
You would make a lot of people happy!  ;)
Title: Re: Including C headers in NASM
Post by: Cyrill Gorcunov on July 06, 2011, 09:34:31 PM
oh, Rob, I still didn't manage with a way more trivial things in nasm, no time :( But I would like you to pull into development team :) Mind to try to enhance nasm? :D
Title: Re: Including C headers in NASM
Post by: Cyrill Gorcunov on July 06, 2011, 09:44:35 PM
I mean I don't lose the hope to pull you into dev team ;)
Title: Re: Including C headers in NASM
Post by: Rob Neff on July 07, 2011, 09:27:12 PM
If I can find some free time this month or next I just might be motivated enough to take a shot at it  ;)