Author Topic: Including C headers in NASM  (Read 26755 times)

Offline jsvcycling

  • Jr. Member
  • *
  • Posts: 2
  • Country: us
  • "Hello World!"
Including C headers in NASM
« 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
Thanks,
Jsvcycling

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Including C headers in NASM
« Reply #1 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


Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: Including C headers in NASM
« Reply #2 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.

Offline jsvcycling

  • Jr. Member
  • *
  • Posts: 2
  • Country: us
  • "Hello World!"
Re: Including C headers in NASM
« Reply #3 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
Thanks,
Jsvcycling

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: Including C headers in NASM
« Reply #4 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 ;)

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Including C headers in NASM
« Reply #5 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

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: Including C headers in NASM
« Reply #6 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 :)

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Including C headers in NASM
« Reply #7 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 asking for that feature.
You would make a lot of people happy!  ;)

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: Including C headers in NASM
« Reply #8 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

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: Including C headers in NASM
« Reply #9 on: July 06, 2011, 09:44:35 PM »
I mean I don't lose the hope to pull you into dev team ;)

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Including C headers in NASM
« Reply #10 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  ;)