Home > OS >  g std=c 98 doesn't compile in MinGW
g std=c 98 doesn't compile in MinGW

Time:12-07

Here's my code:

main.cpp

#include <iostream>
#include <cmath>
using namespace std;
    
int main()
{
    cout << pow(4, 3);
    cin.get();      
}

So basically I try to compile with command g main.cpp -std=c 98

Here's what I get:

    C:\Users\NullPointerException\Desktop\cpp>g   main.cpp -std=c  98
    In file included from c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \bits\postypes.h:40,
                     from c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \iosfwd:40,
                     from c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \ios:38,
                     from c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \ostream:38,
                     from c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \iostream:39,
                     from main.cpp:1:
    c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \cwchar:166:11: error: '::vfwscanf' has not been declared
      166 |   using ::vfwscanf;
          |           ^~~~~~~~
    c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \cwchar:172:11: error: '::vswscanf' has not been declared
      172 |   using ::vswscanf;
          |           ^~~~~~~~
    c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \cwchar:176:11: error: '::vwscanf' has not been declared
      176 |   using ::vwscanf;
          |           ^~~~~~~
    c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \cwchar:193:11: error: '::wcstof' has not been declared
      193 |   using ::wcstof;
          |           ^~~~~~
    In file included from c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \bits\locale_facets.h:39,
                     from c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \bits\basic_ios.h:37,
                     from c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \ios:44,
                     from c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \ostream:38,
                     from c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \iostream:39,
                     from main.cpp:1:
    c:\mingw\lib\gcc\mingw32\9.2.0\include\c  \cwctype:89:11: error: '::iswblank' has not been declared
       89 |   using ::iswblank;
          |           ^~~~~~~~

Basically I wanted to test if c can deduce type for pow. But I get these errors. What's the problem and how do I fix it?

g version: 9.2.0

CodePudding user response:

I can compile this without problems using g 9.3 on ubuntu. Seems you have run into a bug specific to the mingw32 variant of g . You might try adding include <cstdio> and perhaps also include <cstdarg> before the other includes. I cannot test this since I'm not using mingw32.

CodePudding user response:

pow is a C function, not C , so use the alternative C header for the math library.

  • Related