1

I installed mingw on linux and tried compiling a code for windows, this code is intended for posix systems, because I use the% m converter, but realize that when using the _POSIX_C_SOURCE 200112L macro, I can use the converter, so mingw provides a library C that supports the posix pattern?

#define _POSIX_C_SOURCE 200112L
#include <stdio.h>

int main(void){
    char *a;  
    scanf("%ms", &a);
    puts(a);
    return 0;
}
Yuri Albuquerque
  • 474
  • 3
  • 14

1 Answers1

3

MinGW supports a subset of POSIX-like features (%ms, alarm, signal, etc.) on top of MSVCRT, but it's not POSIX-compliant. If you need a POSIX-compliant environment on Windows, use Cygwin.

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
  • @GemTaylor Doesn't always work... Take `opendir` for example. – S.S. Anne Jul 04 '19 at 18:07
  • 2
    But we aren't, we are taking printf :-) In this case it is an option. Not a pleasant one, I admit. The main issue with musl opendir, from memory, is you have to take all their dir methods for consistency. – Gem Taylor Jul 04 '19 at 18:13
  • @GemTaylor If I (personally) wanted to crib some code, I'd crib my own: https://raw.githubusercontent.com/JL2210/minilibc/master/src/stdio/vsnprintf.c – S.S. Anne Jul 04 '19 at 18:14
  • 1
    As they say on the BBC - "other open source, non-restrictive licence libc implementations are available" – Gem Taylor Jul 05 '19 at 10:01
  • @GemTaylor Try searching up that "quote" on Google -- see what you get. – S.S. Anne Jul 05 '19 at 12:09
  • 1
    Sorry, context humour error, clearly! The BBC is has a reputation for claimed impartiality. Anytime anyone mentions a brand name, someone else has to say "Other fizzy drinks are available", as appropriate. – Gem Taylor Jul 05 '19 at 12:37
  • @GemTaylor No, I mean literally; try it out. – S.S. Anne Jul 05 '19 at 16:09