This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

scanf and m modifier

The m modifier is handled just fine by the compiler, but
the results of using it are different on Cygwin than on several other systems
I've tried. Here is a sample program:
#include <stdio.h>
#include <stdlib.h>
#define NAMELEN 100
int main(void) {
  char *f =
"inputstring", title[NAMELEN], *buffer = 0;
  int scanrc;
  scanrc =
sscanf(f, "%ms", &buffer);
  if (scanrc <
1) {
sizeof(title), "sscanf failed");
  } else {
sizeof(title), "%s", buffer);
  printf("title is %s.\n", title);
  return 0;
The expected result is "title is inputstring",
which is what I see on Ubuntu and RedHat systems.
What I see in Cygwin is "sscanf failed".
My compile command is:
gcc -Wall program.c
No warnings are issued. I have also tried adding various
flavors of -D_XOPEN_SOURCE and -D_POSIX_SOURCE, all without success. Is there
some compile option I need to add, or is my program wrong, or is there a

problem with the library code in Cygwin?

BTW, on a very old Solaris system with a very old version of gcc (3.3), I did receive the following message:
replscan3.c:7: warning: unknown conversion type character `m' in format
That is far from ideal, but it is better than the inconsistency between the compiler and the run-time which I'm seeing in Cygwin.

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]