News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Converting c header to include file (h2inc issue)

Started by mnemonic, May 24, 2005, 01:18:33 PM

Previous topic - Next topic

mnemonic

Hi all,

after searching this forum and the old forum as well I´m kind of stuck at generating a include file from a c header file. Even google didn´t yield any results but the old h2inc tool which doesn´t really work...
I especially need to convert the jni.h file that comes together with the Java Development Kit but it seems as if this issue should be discussed in general as it is some common task.

Does anyone know a good tool which is capable of doing that task?

I also read something about using cl from Toolkit 2003 to create a specific file and then using h2inc with that file.
If this method works could someone please explain how it is done in detail?
I tried the "/EP" switch from cl to do some preprocessing and redirected the output into a file and then tried to use h2inc with that file but it just gave me errors again...

The error messages:
C:\Programme\Java\jdk1.5.0_02\include\h2inc>h2inc jni_tst.h
Microsoft (R) C to MASM Include File Translator 6.12a Mar 17 1994 02:11:52
Copyright (c) Microsoft Corp 1994.  All rights reserved

jni_tst.h(243) : warning HI4820: ignoring function definition : __int64()
jni_tst.h(243) : error HI2061: syntax error : identifier 'fpos_t'


If I was just to stupid to do good searching please trash this thread and give me a link to the right place. Thanks :thumbu

Regards, Jens

EDIT:
Maybe I should add the original line which produces the error...
From jni_tst.h line 243:
typedef __int64 fpos_t;
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

hutch--

I have not seen a decent automatic C to assembler header converter since the old h2inc utility ceased to work properly. The problem is that the current batch of C/C++ include files are a power more complicated than the old ones and about the only thing I can see that would perform the task is a utility written something like a C compiler front end. I have from time to time automated bits of this capacity but it still leaves a massive amount of work once the utility has run and short of a C compiler front end, I cannot see another way to do this task.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Tedd

I did start a perl script to do some of this task, but didn't end up getting too far before it got overly complex.
The best bet for now is to do it largely by hand, making liberal use of a text-editor's search and replace functions :wink
No snowflake in an avalanche feels responsible.

gabor

Hello!


I've recently bumped into the same need. I'd like to convert the DirectX SDK header files into MASM includes. Of course a utility capable of this operation could be used for converting every kind of C header files. Is it an impossible mission? Or is there a faint hope to search and find a tool? Or to create a new one?

I personally like to create converters, parsers; so a task like this would be a worthy challenge (and really usefull). But before any investment and effort I'd like to hear your opinions how difficult this could be?


Hutch,
if I decided to code a utility would you support me with some components you wrote about in other topics? (Like hashing, symbol storing-retrival...)

Greets, Gábor

hutch--

gabor,

You are welcome to use any of the stuff I have posted but sad to say the best hash table I have done recently was in PowerBASIC as I wanted the dynamic string to keep the table size down and it won't directly translate into MASM. One trick is to use CL.EXE to get the structures for an include file but the equates need to be obtained by scanning the entire file and doing your own conversions on the fly.

The complexity of the PLATFORMSDK headers make this type of task a very difficult one to perform and you tend to have to do it in bits here and there.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Ossa

Quote from: gabor on May 05, 2006, 10:07:41 AM
I'd like to convert the DirectX SDK header files into MASM includes.

Just in case you're not aware, there have been several posts of already converted DX9 includes. (Note that there are a few (but luckily non-essential) files that CANNOT be converted to MASM syntax - most notably a few of the DX helper lib includes because they use classes with overloaded functions, which CL and ML "name mangle" differently.)

Never-the-less, such a tool would be useful.

(if you want a link to one of the ports of the DX includes, PM me and i'll try to find them again),
Ossa
Website (very old): ossa.the-wot.co.uk