cc std=c11 breakage in Fedora 21

Chuck Forsberg WA7KGX caf at omen.com
Fri Oct 10 14:23:02 UTC 2014


Why does this program fragment fail to compile if a C standard
is specified?  I compiles without complaint with a simple cc -c qq.c

cat qq.c
/*
  cc -c -std=c11 qq.c
     This file (qq.c) compiles without the -std=c11 flag
      or -std=c89 or std=c90 or any std= I tried,
       even -ansi

qq.c: In function ‘sutime’:
qq.c:32:28: error: ‘S_IFMT’ undeclared (first use in this function)
   if (Usemtime && (Filemode&S_IFMT) == S_IFREG)

*/

#include <stdio.h>
#include <sys/types.h>
#include <utime.h>

#include <fcntl.h>
#include <sys/stat.h>
#include <time.h>

#define PATHLEN 1024
extern char Rname[PATHLEN];
extern int Filemode;        /* Unix style mode for incoming file */
extern int Usemtime;        /* <>0: Accept file mod time */



void
sutime(s, ti)
char *s;  time_t ti;
{
     struct utimbuf times;

     if (ti && Usemtime) {
         times.actime = time(NULL);
         times.modtime = ti;
         if (utime(s, &times))
             printf("Can't set file time to 0%lo\n", ti);
     }
     if (Usemtime && (Filemode&S_IFMT) == S_IFREG)
         chmod(Rname, (mode_t)(07777 & Filemode));
}


-- 
      Chuck Forsberg WA7KGX   caf at omen.com   www.omen.com
Developer of Industrial ZMODEM(Tm) for Embedded Applications
   Omen Technology Inc      "The High Reliability Software"
10255 NW Old Cornelius Pass Portland OR 97231   503-614-0430



More information about the test mailing list