RE: Comedi Lib Header translation, was: h2pas enum error

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RE: Comedi Lib Header translation, was: h2pas enum error

Hartmut Eilers
Sorry for coming back on this so late, but I was busy with other projects:

>>While trying to translate comedi.h with:

>>h2pas  -e -D -p -w -u comedi  -l comedi -o comedi.pas comedi.h

>>I get the messages:
>>at line 495 error : syntax error
>>at line 498 error : syntax error
>>Internal error 1 in line 498

>> comedi.h:
>>
>>     494
>>     495 static inline unsigned NI_USUAL_PFI_SELECT(unsigned pfi_channel)
>>     496 {
>>     497         if(pfi_channel < 10)
>>     498                 return 0x1 + pfi_channel;
>>     499         else
>>     500                 return 0xb + pfi_channel;
>>     501 }
>>
>>
>> is the inline the problem ?

>If it is you can resolve it using the C preprocessor using a command
>line similar to this one:

>cpp --no-stdinc comedi.h > comedi.cpped.h

>Afterwards try h2pas again.

I tried the above mentioned fix with the following result:

hartmut@canis:~/src/OpenMSR/PhysMach/comedi $ cpp --no-stdinc comedi.h
> comedi.cpped.h
cc1: error: unrecognized command line option "-fno-stdinc"

This commandline option is not recognized by the compiler, hmmm.

Could anybody lend me a hand with the translation of the comedi header files ?
Any hints are highly appreciated. Are there other tools I can use ?
Hints on other
docs / examples ?

Thanks in advance for your help
Hartmut


--
Hartmut Eilers                          <[hidden email]>
http://www.openmsr.org/            http://www.eilers.net
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: RE: Comedi Lib Header translation, was: h2pas enum error

Henry Vermaak
On 20 May 2010 10:21, Hartmut Eilers <[hidden email]> wrote:
> hartmut@canis:~/src/OpenMSR/PhysMach/comedi $ cpp --no-stdinc comedi.h
>> comedi.cpped.h
> cc1: error: unrecognized command line option "-fno-stdinc"
>
> This commandline option is not recognized by the compiler, hmmm.

Try cpp -nostdinc.  After this, comment out all of the functions in
the file (just search for "return").  h2pas will then parse the file
successfully, after which you can rewrite the functions you've
commented out (they are simple).

Henry
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: RE: Comedi Lib Header translation, was: h2pas enum error

Schindler Karl-Michael-2
In reply to this post by Hartmut Eilers
Am 20.05.2010 um 11:21 schrieb Hartmut Eilers:

>> If it is you can resolve it using the C preprocessor using a command
>> line similar to this one:
>
>> cpp --no-stdinc comedi.h > comedi.cpped.h
>
>> Afterwards try h2pas again.
>
> I tried the above mentioned fix with the following result:
>
> hartmut@canis:~/src/OpenMSR/PhysMach/comedi $ cpp --no-stdinc comedi.h
>> comedi.cpped.h
> cc1: error: unrecognized command line option "-fno-stdinc"
>
> This commandline option is not recognized by the compiler, hmmm.

Accodring to the man page of cpp there is -nostdinc. But even after trying it, the problem remains.

> Could anybody lend me a hand with the translation of the comedi header files ?
> Any hints are highly appreciated. Are there other tools I can use ?
> Hints on other
> docs / examples ?

h2pas only does the simple direct stuff.

All the rest needs manual replacement.

As much as I know unsigned corresponds to unsigned int.
static inline seems to be the problem.

Example (line 393):

static inline unsigned NI_USUAL_PFI_SELECT(unsigned pfi_channel)
{
        if(pfi_channel < 10)
                return 0x1 + pfi_channel;
        else
                return 0xb + pfi_channel;
}

unsigned int NI_USUAL_PFI_SELECT(unsigned int pfi_channel);

there are about 15 similar cases. At least this gives a start.

Maybe you need a translation of the function in the implementation section.

You may also need to add functions for the macros in /* range stuff */ and /* packs and unpacks a channel/range number */

check for " { was #define dname(params) para_def_expr } " in the resulting .pp file.

Finally, I prefer to use ctypes. So, unsigned int becomes cuint, float cfloat and so on. It makes checking easier.

Michael Schindler
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal