OSDN Git Service

2ae6cfcb13f8bcf31478f28f6b81db8ab2757f4e
[mingw/website.git] / faq.html
1 <!DOCTYPE HTML><!--
2  *
3  * faq.html
4  *
5  * MinGW.OSDN frequently asked questions.
6  *
7  *
8  * $Id$
9  *
10  * Written by Keith Marshall <keith@users.osdn.me>
11  * Copyright (C) 2021, MinGW.OSDN Project
12  *
13  *
14  * Redistribution and use in source and 'compiled' forms (SGML, HTML,
15  * PDF, PostScript, RTF, etc) with or without modification, are permitted
16  * provided that the following conditions are met:
17  *
18  * 1. Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions and the following disclaimer as
20  *    the first lines of this file, unmodified.
21  *
22  * 2. Redistributions in compiled form (transformed to other DTDs,
23  *    converted to PDF, PostScript, RTF and other formats) must
24  *    reproduce the above copyright notice, this list of conditions
25  *    and the following disclaimer in the documentation and/or other
26  *    materials provided with the distribution.
27  *
28  * THIS DOCUMENTATION IS PROVIDED BY THE MINGW.OSDN PROJECT "AS IS"
29  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE MINGW.OSDN PROJECT, OR
32  * ITS CONTRIBUTORS, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
39  * DAMAGE.
40  *
41  *
42  * Note: this page assumes browser support for the following numeric
43  * HTML entity codes:
44  *
45  *    &#8209;   non-breaking hyphen
46  *    &#8216;   typographic left (opening) single quote
47  *    &#8217;   typographic apostrophe/right (closing) single quote
48  *    &#8220;   typographic left (opening) double quote
49  *    &#8221;   typographic right (closing) double quote
50  *
51 -->
52 <script class="masthead">
53  set_page( "title", "MinGW.OSDN Frequently Asked Questions" );
54  var group = 0, questions = document.getElementsByClassName( "faq" );
55
56  function show_answer( item, view )
57  { if( (item = item.nextElementSibling).classList.contains( "answer" ) )
58      item.style.display = view ? "block" : "none";
59  }
60  while( group < questions.length )
61  { var entry, query = questions[group++].getElementsByTagName( "button" );
62    for( entry = 0; entry < query.length; entry++ )
63    { query[entry].onclick = function()
64      { show_answer( this, this.classList.toggle( "open" ) ); }
65    }
66  }
67 </script><!-- masthead -->
68 <p>This document presents a categorized list of questions,
69 and answers, relating to the MinGW.OSDN software distributions,
70 and their use.
71 </p>
72 <p>The answer to each question may be revealed,
73 immediately below it, by clicking on the question itself.
74 In the case of questions for which the answer is already visible,
75 a further click on the question will dismiss the view of the answer.
76 </p>
77 <div style="display: none">
78 <!-- template -~- copy & paste next 6 lines to create a Q&A container -->
79 <button>?</button>
80 <div class="answer">
81 <p>
82 </p>
83 </div><!-- answer -->
84 </div><!-- template -->
85 <div class="overlapped faq" id="general">
86 <h3>General Enquiries</h3>
87 <button>What is MinGW?</button>
88 <div class="answer">
89 <p>Created by Colin Peters,
90 and released to the public domain,
91 the original MinGW &mdash; or &#8220;Minimalist GNU for Windows&#8221;
92 &mdash; was a system of import libraries, header files, and supporting
93 &#8220;glue&#8221; code, to facilitate the use of Microsoft&#8217;s
94 <code>CRTDLL.DLL</code> &mdash; and later <code>MSVCRT.DLL</code> &mdash;
95 as the primary run&#8209;time support for a native MS&#8209;Windows port
96 of the GNU Compiler Collection (GCC), and its supporting utilities,
97 (which, in turn, were originally provided by Jan&#8209;Jaap van der Heijden).
98 </p>
99 <p>Today, MinGW has become synonymous with the entire system comprising
100 these GNU tools, a significantly extended derivative of Colin&#8217;s
101 original run&#8209;time system, together with complementary import libraries,
102 and headers, to facilitate access to the MS&#8209;Windows&nbsp;API, a further
103 collection of complementary libraries, and utilities, and even the native
104 MS&#8209;Windows environment in which they run, providing a complete
105 Open&nbsp;Source programming tool set which is suitable for the development
106 of native MS&#8209;Windows applications, with no implicit dependency on any
107 3rd&#8209;party C&#8209;Runtime DLL.
108 </p>
109 </div><!-- answer -->
110 <button>What is MSYS?</button>
111 <div class="answer">
112 <p>A contraction of &#8220;Minimal SYStem&#8221;,
113 originally conceived by Earnie Boyd, and implemented as
114 a light&#8209;weight fork of Cygwin&#8209;1.3,
115 MSYS is a Bourne shell command line interpreter system
116 for use on the MS&#8209;Windows platform.
117 Offered as a general purpose alternative to Microsoft&#8217;s
118 <code>cmd.exe</code>, it is accompanied by a small selection
119 of Unix tools, making it particularly suitable,
120 in conjunction with MinGW,
121 for porting of many Open Source applications
122 to the MS&#8209;Windows plarform.
123 </p>
124 </div><!-- answer -->
125 <button>What is W32API?</button>
126 <div class="answer">
127 <p>Created by Anders Norlander,
128 <code>w32api</code> is a system of import libaries, and header files,
129 complementing Colin Peters&#8217; original bindings for Microsoft&#8217;s
130 <code>CRTDLL.DLL</code>, by the addition of bindings for Microsoft&#8217;s
131 32&#8209;bit &#8220;Windows Application Programming Interface&#8221;.
132 </p>
133 </div><!-- answer -->
134 <button>What is the &#8220;mingw&#8209;ports&#8221; framework?</button>
135 <div class="answer">
136 <p>Originally conceived by Earnie Boyd,
137 and promoted under the name &#8220;<code>mingwPORT</code>&#8221;,
138 this is a system of Bourne shell scripts, designed to facilitate
139 building of MinGW applications, by end users, directly from the
140 upstream source code.
141 </p>
142 <p>Unfortunately, as originally conceived,
143 the <code>mingwPORT</code> system exhibited a number of flaws.
144 In recognition of this, Charles (Chuck) Wilson, developed a replacement,
145 derived from Cygwin&#8217;s &#8220;<code>cygport</code>&#8221; system,
146 which he called &#8220;<code>mgwport</code>&#8221;.
147 This, in turn, was found to be rather unsatisfactory,
148 and has since been supplanted by the
149 &#8220;<code>mingw-port</code>&#8221; subsidiary of
150 &#8220;<a rel="noopener noreferrer" target="_blank"
151  href="https://osdn.net/users/keith/pf/mingw.pkg/"
152 >the <code>mingw&#8209;pkg</code> system</a>&#8221;.
153 </p>
154 <p>A list of packages, which are currently
155 distributed via the <code>mingw&#8209;ports</code> framework,
156 may be found within <a rel="noopener noreferrer" target="_blank"
157  href="https://osdn.net/projects/mingw/storage/mingw-ports"
158 >the MinGW File Release System</a>.
159 </p>
160 </div><!-- answer -->
161 <button>How can I get help, if I can&#8217;t find an answer here?</button>
162 <div class="answer">
163 <p>Presumably,
164 you have exhausted all resources on this web&#8209;site,
165 <em>and</em>&hairsp; a search of <em>all</em>&hairsp;
166 of the MinGW mailing&#8209;list archives,
167 (both current,
168 <em>and</em>&hairsp; historical),
169 and you have found
170 nothing pertinent to your problem.
171 You <em>may</em>&hairsp; find an answer
172 on some 3rd&#8209;party web&#8209;site;
173 however,
174 <em>caveat emptor</em>&hairsp;: such web&#8209;sites are often
175 sources of ill&#8209;advised,
176 and even <em>downright wrong</em>&hairsp;,
177 information!
178 Instead,
179 we <em>strongly</em>&hairsp; recommend that
180 you <em>subscribe</em>&hairsp; to the
181 <a target="_blank" href="index.html?page=mailing.html#mingw-users"
182 >MinGW&#8209;Users mailing list</a>,
183 post a message explaining your problem,
184 and ask for advice.
185 </p>
186 </div><!-- answer -->
187 <button>Why do I receive persistent rejection notifications,
188 when I attempt to post messages to the MinGW&#8209;Users mailing list?
189 </button>
190 <div class="answer">
191 <p>To protect the list, and its subscribers,
192 from a proliferation of <em>spam</em>&hairsp;, the
193 <a target="_blank" href="index.html?page=mailing.html#mingw-users"
194 >MinGW&#8209;Users mailing list</a> will reject any messages
195 which are posted by non&#8209;subscribers;
196 thus, to avoid the rejection notifications, you <em>must</em>&hairsp;
197 <a rel="noopener noreferrer" target="_blank"
198  href="https://lists.osdn.me/mailman/listinfo/mingw-users"
199 >subscribe</a>, and you <em>must</em>&hairsp; post <em>only</em>&hairsp;
200 from your subscribed address.
201 </p>
202 </div><!-- answer -->
203 <button>I <em>have</em>&hairsp;
204 subscribed to the MinGW&#8209;Users mailing list;
205 why do I continue to receive rejection notifications,
206 when I post messages?
207 </button>
208 <div class="answer">
209 <p>You may not have fully completed the subscription process.
210 After submitting the <a rel="noopener noreferrer" target="_blank"
211  href="https://lists.osdn.me/mailman/listinfo/mingw-users"
212 >subscription request form</a>, you will receive a confirmation request,
213 (via e&#8209;mail to the address for which you requested your subscription).
214 You <em>must</em>&hairsp; respond to this confirmation request,
215 following the instructions contained therein;
216 until you do so, your subscription will <em>not</em>&hairsp; become active.
217 </p>
218 <p>If you did not receive a confirmation request,
219 then please check that your e&#8209;mail client, or your service provider,
220 has not directed it into your junk folder, (or any other folder which you
221 may not habitually monitor).
222 </p>
223 <p>If you believe that you <em>have</em>&hairsp;
224 completed the subscription process,
225 then please double check that the address from which you are trying to post
226 <em>exactly</em>&hairsp; matches that which you subscribed.
227 You may wish to use the auto&#8209;responding
228 <a href="mailto:mingw-users-request@lists.osdn.me?subject=password"
229 >password reminder request</a>, and/or
230 <a href="mailto:mingw-users-request@lists.osdn.me?subject=help"
231 >subscription help request</a> services to verify the status
232 of your subscription; if you submit a request of each type,
233 in this order, and you receive a response to the help request,
234 but you do not receive a password reminder,
235 then there is no active subscription for your address.
236 </p>
237 <p>If a password reminder request <em>does</em>&hairsp; elicit a reply,
238 but you still receive rejection notifications when you post to the list,
239 then you may have a legitimate justification to
240 <a href="mailto:mingw-users-owner@lists.osdn.me"
241 >seek administrative assistance</a>.
242 </p>
243 </div><!-- answer -->
244 <button>Can I use the administrative address
245 to communicate with the MinGW Developers?
246 </button>
247 <div class="answer">
248 <p><em>Absolutely not</em>&hairsp;!
249 The administrative address is <em>strictly</em>&hairsp; reserved for
250 administrative communications; if you attempt to abuse it for
251 any other purpose, you will receive no reply.
252 </p>
253 </div><!-- answer -->
254 <button>If I cannot use the administrative address,
255 what mechanism <em>is</em>&hairsp; available for direct communication
256 with the MinGW Developers?
257 </button>
258 <div class="answer">
259 <p>You should subscribe, and post a message to the
260 <a target="_blank" href="index.html?page=mailing.html#mingw-users"
261 >MinGW&#8209;Users mailing list</a>.
262 If one of the developers decides that your enquiry merits his,
263 or her attention, he, or she will reply.
264 Any such reply may, or may not, initiate an off&#8209;list dialogue;
265 whether it does so, or not, is at the discretion of the developer;
266 <em>you</em>&hairsp; have no right to,
267 nor should you have any expectation of,
268 such preferential attention.
269 </p>
270 </div><!-- answer -->
271 <button>Is there a release schedule for MinGW software packages?
272 If there is, where can I find it?
273 </button>
274 <div class="answer">
275 <p>There is no formal release schedule.
276 MinGW is developed, and maintained, by a very few unpaid volunteers.
277 Each contributing volunteer will publish updated versions of the packages
278 which they maintain,
279 on an <em>ad hoc</em>&hairsp; basis, as and when they are ready.
280 Attempting to impose a strict schedule will only engender frustration,
281 and will be counterproductive.
282 </p>
283 <p>The next release, of whatever package you are waiting for,
284 will be published when it is ready; if you want it sooner,
285 please feel free to contribute to the effort of getting it ready.
286 </p>
287 </div><!-- answer -->
288 </div><!-- faq -->
289 <div class="overlapped faq" id="compiling">
290 <h3>Compiling and Linking Issues</h3>
291 <button>Why can&#8217;t the MinGW compilers find my project&#8217;s
292 header files?
293 </button>
294 <div class="answer">
295 <p>Unless your project&#8217;s header files are placed in directories
296 which are already in the compiler&#8217;s default &#8220;include file
297 search path&#8221;, <em>you</em>&hairsp; must specify compiler options,
298 such as &#8220;<code>-I</code>&nbsp;<code><em>path</em></code>&thinsp;&#8221;,
299 &#8220;<code>-iquote</code>&nbsp;<code><em>path</em></code>&thinsp;&#8221;, or
300 &#8220;<code>-isystem</code>&nbsp;<code><em>path</em></code>&thinsp;&#8221;,
301 to indicate where your header files may be found.
302 </p>
303 <p>A comprehensive discussion of this issue, and potential solutions,
304 may be found in <a target="_blank" href="index.html?page=isystem.html"
305 >this MinGW user guide</a>.
306 </p>
307 </div><!-- answer -->
308 <button>How do I specify the libraries to be searched by the MinGW linker?
309 </button>
310 <div class="answer">
311 <p>Assuming that your libraries are correctly named,
312 according to one of the conventions described in
313 <a target="_blank" href="index.html?page=libspec.html"
314 >this user guide</a>, you should add references of the form
315 &#8220;<code>-l<em>name</em></code>&thinsp;&#8221; for each required library,
316 ensuring that each such reference is placed <em>after</em>&hairsp;
317 all named source and object files which refer to it,
318 <em>and</em>&hairsp;, if any library refers to another,
319 that the <em>referring</em>&hairsp; library is named <em>before</em>&hairsp;
320 any to which it refers; (note: in the event of circular
321 references among libraries &mdash; a design fault &mdash;
322 this may require some libraries to be named more than once).
323 </p>
324 <p>Moreover, if any named library cannot be found in the
325 linker&#8217;s default search path, you may also need to specify
326 &#8220;<code>-L</code>&nbsp;<code><em>path</em></code>&thinsp;&#8221;
327 options, as advised in
328 <a target="_blank" href="index.html?page=libpath.html"
329 >this additional user guide</a>.
330 </p>
331 </div><!-- answer -->
332 <button>Why does the MinGW linker
333 persistently report &#8220;undefined reference&#8221; errors,
334 when I have specified all of the libraries
335 which are required to link my application?
336 </button>
337 <div class="answer">
338 <p>There are several reasons why the linker may report
339 &#8220;undefined reference&#8221; errors.
340 Typically, you may be attempting to use a system function,
341 which simply isn&#8217;t natively supported on MS&#8209;Windows,
342 (and thus, is <em>not</em>&hairsp; provided within any MinGW system library);
343 alternatively, you may have neglected to specify some library,
344 which is needed to provide the missing functionality.
345 </p>
346 <p>If you are certain that neither of these is the problem,
347 then it is likely that you are falling foul of a common issue,
348 which is most often entirely attributable to user error:
349 the GNU linker (and hence, the MinGW linker)
350 is a <em>single pass</em>&hairsp; linker, and thus,
351 successful linking is <em>crucially dependent</em>&hairsp; on
352 the order in which source files, object modules,
353 and library references are specified,
354 on the command line;
355 unfortunately,
356 and all too frequently,
357 many <em>users</em>&hairsp; seem to get this <em>fatally wrong</em>&hairsp;.
358 You <em>must</em>&hairsp; ensure that <em>every</em>&hairsp; library reference
359 is placed <em>after</em>&hairsp; every specified object module,
360 (whether explicitly specified, or implicitly compiled),
361 which depends on it.
362 </p>
363 </div><!-- answer -->
364 <button>Why does a compile and link command,
365 which works fine on GNU/Linux,
366 report &#8220;undefined reference&#8221; errors,
367 when invoked <em>identically</em>&hairsp; on MinGW?
368 </button>
369 <div class="answer">
370 <p>Assuming that
371 all of the unresolved references can actually be satisfied,
372 from the set of libraries which have been specified,
373 this is almost certainly another manifestation
374 of the same user error as identified in the previous answer.
375 The order in which sources, object files, and libraries
376 are specified, on the command line, may be incorrect,
377 <em>both</em>&hairsp; for MinGW, <em>and</em>&hairsp; for GNU/Linux;
378 however, the ELF version of the GNU linker,
379 as used on GNU/Linux, may forgive unresolved references,
380 in the particular case of symbols which are defined
381 in a prematurely&#8209;specified <em>shared</em>&hairsp; library,
382 whereas MinGW&#8217;s PE&#8209;COFF linker will <em>not</em>&hairsp;
383 forgive this.
384 </p>
385 <p>That&#8217;s just the way it is.
386 Technically, this is as much an error for the GNU/Linux case,
387 as it is for MinGW; we recommend that you <em>should</em>&hairsp;
388 correct the errant GNU/Linux usage; you <em>must</em>&hairsp;
389 correct it for MinGW.
390 </p>
391 </div><!-- answer -->
392 <button>My application compiles, and links fine,
393 but the executable is <em>huge</em>&hairsp;; why is this?
394 </button>
395 <div class="answer">
396 <p>The most common reason,
397 for executables being larger than expected,
398 is that they include <em>debugging information</em>&hairsp;;
399 (this is added when object modules are compiled with GCC&#8217;s
400 &#8216;<code>&#8209;g</code>&#8217; option).
401 Even if you do not use &#8216;<code>&#8209;g</code>&#8217;,
402 when compiling your own code,
403 some of the libraries with which you link,
404 (including system libraries distributed by MinGW.OSDN),
405 may incorporate debugging information,
406 and this can have a significant effect
407 on the size of executables.
408 </p>
409 <p>If the size of your executables is inflated by debugging information,
410 you may use the <code>strip</code> command to remove it;
411 alternatively, you may specify GCC&#8217;s &#8216;<code>&#8209;s</code>&#8217;
412 option, when you link the executables, to achieve the same effect.
413 </p>
414 <p>Other factors,
415 which may contribute to inflation of the size of executables,
416 and the techniques which may be employed to mitigate them,
417 are discussed in the user guide:
418 <a target="_blank" href="index.html?page=exesize.html"
419 >HOWTO Reduce the Size of MinGW Executable Files</a>.
420 </p>
421 </div><!-- answer -->
422 <button>Why does a recompiled executable differ from the original,
423 when I haven&#8217;t changed the source, or any compiler options?
424 </button>
425 <div class="answer">
426 <p>The <em>run&#8209;time behaviours</em>&hairsp; of
427 the two executables should be identical.
428 However, the MinGW GCC compiler <em>does not</em>&hairsp; guarantee
429 to produce consistent output, between any two compilations of the
430 same source; differences in recorded meta&#8209;data, (e.g.
431 compilation date), will be sufficient to introduce byte&#8209;level
432 diferences; furthermore, there is no guarantee that the ordering
433 of the generated code will remain identical.
434 </p>
435 <p>It may be possible to achieve consistent output,
436 by patching GCC itself, but doing so is beyond the scope
437 of MinGW&#8217;s documentation.
438 </p>
439 </div><!-- answer -->
440 <button>What should I do when the compiler reports an
441 &#8220;internal error&#8221;?
442 </button>
443 <div class="answer">
444 <p>If you see a diagnostic message similar to this:
445 </p><pre class="box-out">
446 ../include/wx/ctrlsub.h:156: internal error: Segmentation fault
447 </pre><p>then try running the same compilation command again.
448 </p>
449 <p>If the same error message is reproduced,
450 then you may have stumbled upon a genuine compiler defect.
451 You should try to create a <em>minimal reproducible test case</em>&hairsp;,
452 (i.e.&nbsp;an <a rel="noopener noreferrer" target="_blank"
453  href="http://www.sscce.org"
454 >SSCCE</a>), and post it, along with a request for advice, on the
455 <a target="_blank" href="index.html?page=mailing.html#mingw-users"
456 >MinGW&#8209;Users mailing list</a>;
457 others may have already encountered the same problem,
458 and be able to help.
459 </p>
460 <p>Conversely,
461 if the error is <em>not consistently reproducible</em>&hairsp;,
462 you may have a hardware fault;
463 <a rel="noopener noreferrer" target="_blank"
464  href="https://www.bitwizard.nl/sig11/"
465 >this third&#8209;party FAQ</a> may help to explain the issue.
466 </p>
467 <p>As a work&#8209;around,
468 if you have encountered a <em>persistently reproducible</em>&hairsp;
469 <dfn>ICE</dfn> (internal compiler error), then you may be able
470 to circumvent it by recompiling at a different (likely lower)
471 level of optimization; (however, you should not allow this,
472 if successful, to discourage you from reporting the issue).
473 </p>
474 </div><!-- answer -->
475 </div><!-- faq -->
476 <div class="overlapped faq" id="portability">
477 <h3>Software Portability Issues</h3>
478 <button>Can I use libraries compiled by other compilers,
479 (e.g. MSVC), with MinGW?
480 </button>
481 <div class="answer">
482 <p>This depends on the interfaces exposed by the library.
483 In general, any interface which is exposed using
484 <code>extern</code>&nbsp;<code>&quot;C&quot;</code>
485 linkage, (as is the case for many of the MS&#8209;Windows&nbsp;API
486 library function interfaces), will be compatible; on the other hand,
487 interfaces which are exposed using <code>C++</code> linkage,
488 (or any other language linkage protocol,
489 which is not <em>strictly</em>&hairsp;
490 <code>extern</code>&nbsp;<code>&quot;C&quot;</code> compatible),
491 are unlikely to be usable.
492 </p>
493 </div><!-- answer -->
494 <button>MinGW&#8217;s <code>printf()</code> doesn&#8217;t seem
495 to support the C99 <code>%ll</code> format modifier; how can I format
496 a C99 <code>long</code>&nbsp;<code>long</code> value?
497 </button>
498 <div class="answer">
499 <p>MinGW&#8217;s <code>printf()</code> <em>does</em>&hairsp; support
500 the <code>%ll</code> format modifier; however, Microsoft&#8217;s
501 <code>MSVCRT.DLL</code> implementation, (which is what MinGW uses
502 <em>by default</em>&hairsp;), does not.
503 </p>
504 <p>If you want to continue to use the <code>MSVCRT.DLL</code>
505 implementation of <code>printf()</code>, then to format a C99
506 <code>long</code>&nbsp;<code>long</code> value, you must use
507 Microsoft&#8217;s <em>non&#8209;standard</em>&hairsp; <code>I64</code>
508 format modifier, instead of the standard C99 <code>%ll</code> modifier.
509 </p>
510 <p>Conversely, if you prefer C99 standard <code>printf()</code>
511 compatibility, then you <em>must</em>&hairsp; elect to use the
512 <code>libmingwrt.a</code> implementation of <code>printf()</code>,
513 (and its formatted I/O siblings), when you compile your code;
514 <em>any one</em>&hairsp; of the following
515 <em>formally sanctioned</em>&hairsp;
516 techniques is sufficient to achieve this:
517 </p><ul style="margin-left: -0.8em">
518 <li>Compile your code with GCC&#8217;s <code>-posix</code> option.
519 </li>
520 <li>Permanently <em>enable</em>&hairsp; the <code>__MINGW_ANSI_STDIO__</code>
521 feature, by editing MinGW&#8217;s <code>&lt;features.h&gt;</code> file;
522 (supported from <code>libmingwrt.a</code> version 5.2.1 onwards).
523 </li>
524 <li><code>#define</code> either <code>_GNU_SOURCE</code>, or
525 <code>_BSD_SOURCE</code>, <em>before</em>&hairsp; any <code>#include</code>
526 statement, which may cause any system header file to be included;
527 (neither macro requires an associated value).
528 </li>
529 <li><code>#define</code>&nbsp;<code>_POSIX_C_SOURCE</code>, with
530 any of the non&#8209;zero values specified by the POSIX standard;
531 if unspecified, at the time when the first <code>#include</code>
532 statement, if any, which causes any system header file to be
533 included, MinGW will <em>implicitly</em>&hairsp; behave as if a value
534 of <code>200809L</code> had been specified, but an <em>explicit</em>&hairsp;
535 definition is required, to override the <code>MSVCRT.DLL</code>
536 implementation of <code>printf()</code>.
537 </li>
538 <li><code>#define</code>&nbsp;<code>_XOPEN_SOURCE</code>, with any
539 of the values prescribed by the POSIX standard; once again, such a
540 definition <em>must</em>&hairsp; precede <em>all</em>&hairsp;
541 <code>#include</code> statements which may cause inclusion of
542 any system header file; it has the same effect as an <em>explicit</em>&hairsp;
543 definition of <code>_POSIX_C_SOURCE</code>,
544 at the equivalent conformity level.
545 </li></ul>
546 </div><!-- answer -->
547 </div><!-- faq -->
548
549 <!-- $RCSfile$: end of file -->