OpenTTD source file references "unistd.h" but GCC can't find this function: fdatasync(int)

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

OpenTTD source file references "unistd.h" but GCC can't find this function: fdatasync(int)

Joseph Sheppard
Hi,

I've not been able to compile OpenTTD in my Windows 8.1 64bit OS having followed these instructions because GCC can't find this function's declaration:
[SRC] Compiling ini.cpp
C:/MinGW/msys/1.0/trunk/src/ini.cpp: In member function 'bool <a class="moz-txt-link-freetext" href="IniFile::SaveToDis">IniFile::SaveToDisk(const char*)':
C:/MinGW/msys/1.0/trunk/src/ini.cpp:84:31: error: 'fdatasync' was not declared in this scope
  int ret = fdatasync(fileno(f));
                               ^
make[1]: *** [ini.o] Error 1
make[1]: Leaving directory `/usr/trunk/objs/release'
make: *** [all] Error 1


This source file can be viewed here: https://docs.openttd.org/ini_8cpp_source.html

I've seen that the Unix specification of unistd.h declares this function but I've not found its declaration in the MinGW unistd.h and its included source files.

I'm a new MinGW user having installed it yesterday and I've only installed OpenTTD's required libraries:

My CPATH directory is: C:/MinGW/msys/1.0/local/include

My LIBRARY_PATH directory is: C:/MinGW/msys/1.0/local/lib

Installed MinGW packages:

* mingw32-base
* mingw32-gcc g++
* msys-base


Does anyone know what I'm doing wrong?




------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe

configure_output.txt (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: OpenTTD source file references "unistd.h" but GCC can't find this function: fdatasync(int)

Gisle Vanem-2
Joseph Sheppard wrote:

> I've not been able to compile OpenTTD <https://www.openttd.org/en/>in my Windows 8.1 64bit OS having followed these
> <https://wiki.openttd.org/Compiling_on_Windows_using_MinGW#Compiling_OpenTTD>instructions because GCC can't find this
> function's declaration:
>
>     /[SRC] Compiling ini.cpp//
>     //C:/MinGW/msys/1.0/trunk/src/ini.cpp: In member function 'bool IniFile::SaveToDis//k(const char*)'://
>     //C:/MinGW/msys/1.0/trunk/src/ini.cpp:84:31: error: 'fdatasync' was not declared i//n this scope//
>     //  int ret = fdatasync(fileno(f));//

fsync() nor fdatasync() isn't part of MingW, but can easily
be replaced by:

   #include <io.h>

   extern __inline__ int fdatasync (int fd)
   {
     return _commit(fd);
   }

(or a macro).

The POSIX distinction between fsync() and fdatasync() is probably
not important for OpenTTD. Looking at:
  http://git.openttd.org/?p=trunk.git;a=blob;f=src/ini.cpp;h=ccce1923937964795d49df48645bf0ea6e4412da;hb=HEAD

the code around 'WITH_FDATASYNC' looks fishy.

Ref:
   https://msdn.microsoft.com/en-us/library/17618685.aspx?f=255&MSPPError=-2147217396


--
--gv

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenTTD source file references "unistd.h" but GCC can't find this function: fdatasync(int)

Joseph Sheppard
Thanks for helping me Gisle.

On 19/05/2015 14:33, Gisle Vanem wrote:

> Joseph Sheppard wrote:
>
>> I've not been able to compile OpenTTD <https://www.openttd.org/en/>in my Windows 8.1 64bit OS having followed these
>> <https://wiki.openttd.org/Compiling_on_Windows_using_MinGW#Compiling_OpenTTD>instructions because GCC can't find this
>> function's declaration:
>>
>>      /[SRC] Compiling ini.cpp//
>>      //C:/MinGW/msys/1.0/trunk/src/ini.cpp: In member function 'bool IniFile::SaveToDis//k(const char*)'://
>>      //C:/MinGW/msys/1.0/trunk/src/ini.cpp:84:31: error: 'fdatasync' was not declared i//n this scope//
>>      //  int ret = fdatasync(fileno(f));//
> fsync() nor fdatasync() isn't part of MingW, but can easily
> be replaced by:
>
>     #include <io.h>
>
>     extern __inline__ int fdatasync (int fd)
>     {
>       return _commit(fd);
>     }
>
> (or a macro).
>
> The POSIX distinction between fsync() and fdatasync() is probably
> not important for OpenTTD. Looking at:
>    http://git.openttd.org/?p=trunk.git;a=blob;f=src/ini.cpp;h=ccce1923937964795d49df48645bf0ea6e4412da;hb=HEAD
>
> the code around 'WITH_FDATASYNC' looks fishy.
>
> Ref:
>     https://msdn.microsoft.com/en-us/library/17618685.aspx?f=255&MSPPError=-2147217396
>
>


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenTTD source file references "unistd.h" but GCC can't find this function: fdatasync(int)

Keith Marshall-3
In reply to this post by Gisle Vanem-2
On 19/05/15 14:33, Gisle Vanem wrote:
> fsync() nor fdatasync() isn't part of MingW,

They aren't even guaranteed to be supported by a POSIX conforming
system, since both are designated as "optional", (which means that
applications wishing to use them should check the applicable feature
test macros, to ensure that they are provided); since MinGW defines
*neither* _POSIX_FSYNC *nor* _POSIX_SYNCHRONIZED_IO, it should be clear
that neither function will be supported, and there is therefore no
requirement, (even under POSIX.1-2008), to provide so much as even a
stub implementation.

> ...snip...
>
> the code around 'WITH_FDATASYNC' looks fishy.

Agreed; very fishy indeed, for there appears to be no attempt whatsoever
to check API availability, before gratuitously assuming support.  You
should report this as an OpenTTD bug.

--
Regards,
Keith.

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenTTD source file references "unistd.h" but GCC can't find this function: fdatasync(int)

Joseph Sheppard
Thanks for your input Kieth.

I've reported this problem and quoted your email in a OpenTTD forum topic and will fix it myself when I have time, if no else fixes it.

On 20/05/2015 12:31, Keith Marshall wrote:
On 19/05/15 14:33, Gisle Vanem wrote:
fsync() nor fdatasync() isn't part of MingW,
They aren't even guaranteed to be supported by a POSIX conforming
system, since both are designated as "optional", (which means that
applications wishing to use them should check the applicable feature
test macros, to ensure that they are provided); since MinGW defines
*neither* _POSIX_FSYNC *nor* _POSIX_SYNCHRONIZED_IO, it should be clear
that neither function will be supported, and there is therefore no
requirement, (even under POSIX.1-2008), to provide so much as even a
stub implementation.

...snip...

the code around 'WITH_FDATASYNC' looks fishy.
Agreed; very fishy indeed, for there appears to be no attempt whatsoever
to check API availability, before gratuitously assuming support.  You
should report this as an OpenTTD bug.



------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe