Can't compile SQLCMD
Posted in 2015
Topics: General Discussion
I'm struggling to build sqlcmd on Redhat 6.7. RHEL6.7 is shipped with GCC 4.4.7 and I'm getting the error "#pragma GCC Diagnostic not allowed inside functions" (initially this occurs during the compile of ensprintf.c). I have a feeling this might be a bug in GCC 4.4.7. Does anyone have any work arounds or suggestions?
I modified esnprinf.c (lines 29,30,32) and stderr.c (lines 361,362,364) and removed the #pragma directives and everything compiled ok.
Well done on resolving the problem. I'll look into this, but I'm not sure that I necessarily want to support such ancient versions of GCC. I know; RHEL 6 is relatively modern (first release 2010; still in production 1 phase until 2016Q2), even if the compiler that ships with it is not. It makes life difficult or a maintainer. Clang (as provided by Apple in XCode 7.0.1) and GCC 5.2.0 do not have a problem with the code. I'll see whether I can stomach moving the lines outside the function they're in to pacify GCC 4.4.x, or removing the pragmas altogether. Can you confirm that if, instead of removing the directives altogether, you move the two before the 'printf' family function call so that they are outside the function, and move the one line after the 'printf' family function so that it is after the function, then the code compiles on GCC 4.4.x without a warning? Please reply direct to me rather than to the mailing list; it is useful for people to know that there's a problem and if necessary a workaround, but they don't need all the further analysis and diagnostics, etc. The functions are small enough that I'd be OK with doing that to make it compile. The pragma quells a semi-valid warning from compilers set exceptionally extremely fussy about calling the 'printf' family functions with a format string that is not a string literal but is computed or passed to the function somehow. If you want to know how fussy compilers can be, get a modern version of clang and use -Weverything as an option on some C code. Don't be surprised when you get a lot of warnings; you will almost inevitably get them even if you think you've been extremely careful with your coding. (I don't think I've run all of SQLCMD through 'clang -Weverything' yet.) However, it also means it is in many ways cosmetic; you've certainly done no harm by removing the pragma lines. Maybe I should treat those lines as 'maintainer-version only' and strip them from the distributed code On Sun, Oct 18, 2015 at 5:55 PM, RAY BURNS <ray.burns@velocityglobal.co.nz> wrote: > I modified esnprinf.c (lines 29,30,32) and stderr.c (lines 361,362,364) and > removed the #pragma directives and everything compiled ok. > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > -- Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h> Guardian of DBD::Informix - v2015.0826 - http://dbi.perl.org "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." --001a11c126e884b6770522714a2d