Web lists-archives.com

Re: [Mingw-users] How do I write native windows code with MinGW? POSIX calls are compiling?.




On 3/17/2017 4:25 AM, Eli Zaretskii wrote:
>> Date: Thu, 16 Mar 2017 19:33:05 -0400
>> From: kk.mingw@xxxxxxxxxxxxxxx
>>
>> How do I write native windows code with MinGW? Getting POSIX calls to 
>> compile.
> 
> There's no single answer to that, it depends on the APIs you need.
> But as a rule of thumb, mots Posix APIs are absent.
> 
>> Exactly what I want – Let me explain. I followed the directions for a 
>> new instillation. I have a Linux program that works in Linux. It will 
>> also work in Cygwin. The program has several POSIX calls that I know 
>> windows does NOT support (getopt(), glob(), ...). I tried compiling this 
>> program with MinGW expecting errors --- but to my surprise it compiles, 
>> links, and runs. Clearly, it has linked with some libs that provide 
>> POSIX – how do I get Windows and nothing but windows?
> 
> MinGW adds a small set of popular Posix functions in the libmingwex
> library that is scanned by default by the linker when linking
> programs.  If you want to know which additional functions are
> available, use something like 'nm -A libmingwex.a | grep " T "', and
> you will see them.  Most of them are math functions, but some, like
> getopt and glob, are not.
> 

Don't forget though that all of those symbols may not be declared due to
defined constants which get defined by various methods.  If you want to
eliminate the POSIX emulations use -std=c## where ## is replaced by your
favorite standard version moniker e.g. -std=c99.  I also suggest using
-Wall -Werror if you want to ensure that there are no hidden issues.

-- 
Earnie

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

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:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe