C Header to .bi

General FreeBASIC programming questions.
Dinosaur
Posts: 1350
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

C Header to .bi

Postby Dinosaur » Feb 02, 2018 14:03

Hi All

I haven't followed the progress on this subject for many years, but do recall a member
writing a program called h_2_bi.
I have tried every search term in my Jurassic brain but can't get a hit.

Does anyone know of an updated solution or a link to the OP.?

Regards
srvaldez
Posts: 2464
Joined: Sep 25, 2005 21:54

Re: C Header to .bi

Postby srvaldez » Feb 02, 2018 14:09

Dinosaur
Posts: 1350
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: C Header to .bi

Postby Dinosaur » Feb 02, 2018 16:28

Hi All

Thanks srvaldez,
I don't know how you find that so quick, but the search facility on the FB Forum frustrates me.
Why can't i simply search for ONE word "h_2_bi".

Either way, fbfrog does the trick nicely.

Regards
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: C Header to .bi

Postby lizard » Feb 02, 2018 16:56

You can search with google, it usually gives results:

https://www.google.de/search?source=hp& ... g9AVjmnxwk
Dinosaur
Posts: 1350
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: C Header to .bi

Postby Dinosaur » Feb 02, 2018 17:58

Hi All

Using FBFrog on a .h file creates lots of "Not Found" .h files.

For example

Code: Select all

   bits/wchar.h (not found)
   bits/wordsize.h (not found)
   AIOUSB_Core.h
   AIOUSBDevice.h
   AIOTypes.h
   /usr/include/stdlib.h
   stddef.h (not found)
   bits/waitflags.h (not found)
   bits/waitstatus.h (not found)
   sys/types.h (not found)
   /usr/include/alloca.h
   stddef.h (not found)
   bits/stdlib-float.h (not found)
   /usr/include/assert.h
   /usr/include/errno.h
   bits/errno.h (not found)
   ADCConfigBlock.h
   AIOEither.h
   /usr/include/stdlib.h
   /usr/include/string.h
   stddef.h (not found)
   /usr/include/xlocale.h
   /usr/include/stdlib.h
   USBDevice.h
   libusb.h (not found)
   /usr/include/stdlib.h
   AIOPlugNPlay.h
   cJSON.h
   /usr/include/semaphore.h
   sys/types.h (not found)
   /usr/include/time.h
   bits/types.h (not found)
   bits/semaphore.h (not found)
   libusb.h (not found)
   /usr/include/pthread.h
   /usr/include/endian.h
   bits/endian.h (not found)
   bits/byteswap.h (not found)
   /usr/include/sched.h
   bits/types.h (not found)
   stddef.h (not found)
   /usr/include/time.h
   bits/types.h (not found)
   bits/sched.h (not found)
   /usr/include/time.h
   stddef.h (not found)
   bits/time.h (not found)
   bits/types.h (not found)
   bits/types.h (not found)
   bits/types.h (not found)
   bits/pthreadtypes.h (not found)
   bits/setjmp.h (not found)
   bits/wordsize.h (not found)
   libusb.h (not found)
   /usr/include/stdio.h
   stddef.h (not found)
   bits/types.h (not found)
   /usr/include/libio.h
   /usr/include/_G_config.h
   bits/types.h (not found)
   stddef.h (not found)
   /usr/include/wchar.h
   stdarg.h (not found)
   bits/stdio_lim.h (not found)
   bits/sys_errlist.h (not found)
   /usr/include/stdlib.h
   /usr/include/unistd.h
   bits/posix_opt.h (not found)
   bits/environments.h (not found)
   bits/types.h (not found)
   stddef.h (not found)
   bits/confname.h (not found)
   /usr/include/getopt.h
   sys/stat.h (not found)
   libusb.h (not found)
   AIOChannelMask.h
   /usr/include/stdlib.h
   /usr/include/assert.h
   AIOContinuousBuffer.h
   AIOUSB_ADC.h
   AIOBuf.h
   /usr/include/stdlib.h
   /usr/include/stdio.h
   AIOFifo.h
   /usr/include/stdlib.h
   /usr/include/stdio.h
   AIOCmd.h
   /usr/include/stdlib.h
   /usr/include/stdio.h
   /usr/include/stdlib.h
   libusb.h (not found)
   /usr/include/math.h
   bits/math-vector.h (not found)
   bits/huge_val.h (not found)
   bits/huge_valf.h (not found)
   bits/huge_vall.h (not found)
   bits/inf.h (not found)
   bits/nan.h (not found)
   bits/mathdef.h (not found)
   bits/mathcalls.h (not found)
   bits/mathcalls.h (not found)
   bits/mathcalls.h (not found)
   DIOBuf.h
   /usr/include/assert.h
   /usr/include/stdio.h
   /usr/include/stdlib.h
   sys/stat.h (not found)
   AIODeviceInfo.h
   /usr/include/stdlib.h
   AIODeviceQuery.h
   /usr/include/stdio.h
   /usr/include/stdlib.h
   libusb.h (not found)
   AIOCommandLine.h
   AIOConfiguration.h
   /usr/include/stdlib.h
   /usr/include/stdio.h
   /usr/include/assert.h
   AIODeviceTable.h
   libusb.h (not found)
   /usr/include/stdlib.h
   /usr/include/errno.h
   AIOUSB_Properties.h
   AIOProductTypes.h
   AIOList.h
   CStringArray.h
   sys/queue.h (not found)
   /usr/include/stdio.h
   /usr/include/stdlib.h
   /usr/include/assert.h
   /usr/include/stdio.h
   AIOUSB_Log.h
   /usr/include/stdio.h
   /usr/include/getopt.h
   /usr/include/ctype.h
   bits/types.h (not found)
   /usr/include/stdlib.h
   mex.h (not found)
emitting: libaiousb.bi (2511 declarations, 92 TODOs)
I have added the
./fbfrog -incdir /usr/include libaiousb.h
The missing .h files seem to have their paths incorrectly specified.
Like:
bits/waitflags.h (not found)
Should be:
/usr/include/x86_64-linux-gnu/bits/waitflags.h

How do you normally handle this kind of problem ?
Do you correct the path in the source .h file or do you copy the .h file to another folder.
If correcting the path, how do I know which .h file to find the statement in ?

Regards
Dinosaur
Posts: 1350
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: C Header to .bi

Postby Dinosaur » Feb 02, 2018 21:41

Hi All

I have one issue with a number of C Functions that I don't understand.
The Functions are typically declared as per:
unsigned long AIOUSB_Init()
I then write a small test program as such:

Code: Select all

Extern "C"
    Extern AIOUSB_Init() Alias "AIOUSB_Init()" As Longint
    Extern AIOUSB_ListDevices() Alias "AIOUSB_ListDevices()" As Longint
End Extern
Dim au As Longint
au = AIOUSB_Init(0)
Print au

The error I get is as follows:
/home/barfresh/projects/aiousb/AIOTest.c:40:27: error: lvalue required as unary ‘&’ operand
AU$0 = *(int64*)*(int64*)&AIOUSB_Init();
^
There are descriptions relating to this problem for C/C++ but can't find anything usable in FreeBasic.

Regards
caseih
Posts: 1505
Joined: Feb 26, 2007 5:32

Re: C Header to .bi

Postby caseih » Feb 03, 2018 2:26

You state that the original C prototype is unsigned long AIOUSB_Init(), which takes no arguments, but then you go on to try to call it with 0 as an argument. Is there something missing there?

Anyway your declarations are not correct. try something like:

Code: Select all

Extern "C"
    declare Function AIOUSB_Init Alias "AIOUSB_Init" () As Longint
    declare Function AIOUSB_ListDevices Alias "AIOUSB_ListDevices" () As Longint
End Extern
Dinosaur
Posts: 1350
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: C Header to .bi

Postby Dinosaur » Feb 03, 2018 2:32

Hi All

caseih, I was aware of that, but tried dozens of different ways to call the function
to get rid of the error.

Regards

Return to “General”

Who is online

Users browsing this forum: No registered users and 12 guests