Created attachment 1302790 [details] Log of two compilation runs with the example code. First OK, second fails. Description of problem: On just installed (2 hours ago) Fedora 26 include file <sys/quota.h> pollutes g++ environment so that including <iostream> after <sys/quota.h> produces error. Version-Release number of selected component (if applicable): gcc version 7.1.1 20170622 (Red Hat 7.1.1-3) (GCC) How reproducible: Compile following snippet by [havia@game mailquota]$ g++ err.cpp -c -DERROR_ON=0 All fine [havia@game mailquota]$ g++ err.cpp -c -DERROR_ON=1 Won't compile --- clip --- #if ERROR_ON == 1 #include <sys/quota.h> #include <iostream> #else #include <iostream> #include <sys/quota.h> #endif int func(void) { return 0; } --- clip --- Steps to Reproduce: 1. See test code above. Actual results: Compilation error Expected results: Compilation without errors. Additional info:
This isn't a GCC bug. This also fails: #include <sys/quota.h> #include <errno.h> #ifndef ERANGE #error no ERANGE #endif This is because <sys/quota.h> includes <linux/errno.h> so when <bits/errno.h> includes it again (after doing #undef ERANGE) it doesn't define anything.
That means it is a glibc bug caused by commit 4d728087ef8cc826b05bd21d0c74d4eca9b1a27d Author: Florian Weimer <fweimer> Date: Thu Sep 1 15:53:13 2016 +0200 Base <sys/quota.h> on Linux kernel headers [BZ #20525] Macros which are also defined in <linux/quota.h> are removed, and <linux/quota.h> is included instead. This commit cleans up the definition of fs_to_dq_blocks and struct dqblock and struct dqinfo, too. Either sys/quota.h should ensure linux/errno.h is not included, or should include <errno.h> first or something different that will work.
I posted a kernel patch: http://marc.info/?l=linux-fsdevel&m=150246173513558
Fixed in the kernel with this upstream commit: commit 34fc75bfc616f1c1fbab56508c3f48f4b97c97ea Author: Florian Weimer <fweimer> Date: Fri Aug 11 16:24:15 2017 +0200 uapi/linux/quota.h: Do not include linux/errno.h linux/errno.h is very sensitive to coordination with libc headers. Nothing in linux/quota.h needs it, so this change allows using this header in more contexts.