where is the type FILE defined?

New to FreeBASIC? Post your questions here.
srvaldez
Posts: 2253
Joined: Sep 25, 2005 21:54

where is the type FILE defined?

Postby srvaldez » Oct 13, 2015 15:15

been looking and searching but can't find in which include file is the type FILE defined
been testing the Mac version of fb but get numerous errors like the following
/usr/local/include/freebasic/crt/stdio.bi(34) error 14: Expected identifier, found 'FILE' in 'declare function fopen (byval as zstring ptr, byval as zstring ptr) as FILE ptr'
MrSwiss
Posts: 3367
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: where is the type FILE defined?

Postby MrSwiss » Oct 13, 2015 15:32

;-) try: file.bi
you'll see there is NOT any FILE definition (Attributes etc. are there and some File-Functions, copy etc.)

Why don't you post the code that triggers the above ERROR?
srvaldez
Posts: 2253
Joined: Sep 25, 2005 21:54

Re: where is the type FILE defined?

Postby srvaldez » Oct 13, 2015 15:55

believe me that was one of the first files I looked, but it's actually defined in inc\crt\dos\stdio.bi, fount it using notepad++
but thanks for answering :)
MrSwiss
Posts: 3367
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: where is the type FILE defined?

Postby MrSwiss » Oct 13, 2015 16:33

Code: Select all

#if defined(__FB_WIN32__)
#include once "crt/win32/stdio.bi"
#elseif defined(__FB_DOS__)
#include once "crt/dos/stdio.bi"
#elseif defined(__FB_LINUX__)
#include once "crt/linux/stdio.bi"
#endif

Be carefull with these, because the really used definition of FILE depends on OS!
These defines (above) come from: ".\inc\crt\stdio.bi" which then loads "stdio.bi" from OS subdir ...

On MAC, I'd expect it to be the one in "LINUX", NOT the one in "DOS".
srvaldez
Posts: 2253
Joined: Sep 25, 2005 21:54

Re: where is the type FILE defined?

Postby srvaldez » Oct 13, 2015 17:21

you right that the dos version is not right for os x but the linux definition don't work either
anyway as long as I don't actually use the file functions it's ok.
caseih
Posts: 1425
Joined: Feb 26, 2007 5:32

Re: where is the type FILE defined?

Postby caseih » Oct 13, 2015 18:01

Edited due to reading comprehension failure.
Last edited by caseih on Oct 13, 2015 18:43, edited 1 time in total.
MrSwiss
Posts: 3367
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: where is the type FILE defined?

Postby MrSwiss » Oct 13, 2015 18:32

caseih wrote:It's not necessary to do the #if define platform stuff ...

NO, because the "the #if define platform stuff" is an excerpt from: "crt/stdio.bi".
Reading (and understanding) posts seems to be an Art ;-)
caseih
Posts: 1425
Joined: Feb 26, 2007 5:32

Re: where is the type FILE defined?

Postby caseih » Oct 13, 2015 18:42

Indeed it does seem to be an art.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: where is the type FILE defined?

Postby MichaelW » Oct 14, 2015 1:33

The structure is actually named _iobuf, and for MinGW defined in stdio.h:

Code: Select all

#ifndef _FILE_DEFINED
  struct _iobuf {
    char *_ptr;
    int _cnt;
    char *_base;
    int _flag;
    int _file;
    int _charbuf;
    int _bufsiz;
    char *_tmpfname;
  };
  typedef struct _iobuf FILE;
#define _FILE_DEFINED
#endif

In my quick search I did not find the definition in the header files for FreeBASIC Compiler - Version 1.03.0 (07-01-2015), built for win64 (64bit), but in my quick test a sizeof for both names returned 48, so I assume the structure must be defined somewhere.
MrSwiss
Posts: 3367
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: where is the type FILE defined?

Postby MrSwiss » Oct 14, 2015 8:25

Yes, it's almost the same in "inc\crt\win32\stdio.bi":

Code: Select all

type _iobuf
   _ptr as zstring ptr
   _cnt as long
   _base as zstring ptr
   _flag as long
   _file as long
   _charbuf as long
   _bufsiz as long
   _tmpfname as zstring ptr
end type

type FILE as _iobuf

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 2 guests