[regex]: Why it's failed to build

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[regex]: Why it's failed to build

Jean He
Hi all:

I download MinGW with g++ 4.4, and I can't wait to try it.

I write a sample cpp like this:
#include <regex>
#include <string>
#include <iostream>
using namespace std;

int main()
{
const regex r("[1-9]*x[2-9]+");
for (string s; getline(cin, s); )
{
cout << (regex_match(s, r) ? "Yes" : "No") << endl;
}

        return 0;
}

After I build it, some errors are thrown, I don't know if I miss some options or...

D:\MinGW_Env\Code>g++ -std=c++0x regex.cpp -o regex.exe
In file included from d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/postypes.h:42,
                 from d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/char_traits.h:42,
                 from d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/string:42,
                 from d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/bitset:49,
                 from d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/regex:43,
                 from regex.cpp:1:
d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error: '::swprintf' has not been declared
d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166: error: '::vswprintf' has not been declared

Can you please help me figure out what's wrong in above process, thank you very much in advance.

Thanks,
Mike


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: [regex]: Why it's failed to build

Greg Chicares
On 2010-03-17 14:03Z, Jean He wrote:
>
> D:\MinGW_Env\Code>g++ -std=c++0x regex.cpp -o regex.exe
[...]
> d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error:
> '::swprintf' has not been declared

This search:
  http://www.google.com/search?q="'::swprintf' has not been declared"
suggests that '-std=c++0x' is incompatible with swprintf().

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: [regex]: Why it's failed to build

DouglasA1
If you just want to test your installation, I would suggest you start
with something simpler.

#include <iostream>

int main(int argc, char**argv) {
    // Prints welcome message...
    std::cout << "Welcome ..." << std::endl;

    // Prints arguments...
    //if (argc > 1) {
    //    std::cout << std::endl << "Arguments:" << std::endl;
    //    for (int i = 1; i < argc; i++) {
    //        std::cout << i << ": " << argv[i] << std::endl;
    //    }
    //}

    return 0;
}


On 3/17/10, Greg Chicares <[hidden email]> wrote:

> On 2010-03-17 14:03Z, Jean He wrote:
>  >
>  > D:\MinGW_Env\Code>g++ -std=c++0x regex.cpp -o regex.exe
>
> [...]
>
> > d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error:
>  > '::swprintf' has not been declared
>
>
> This search:
>   http://www.google.com/search?q="'::swprintf' has not been declared"
>  suggests that '-std=c++0x' is incompatible with swprintf().
>
>  ------------------------------------------------------------------------------
>  Download Intel&#174; Parallel Studio Eval
>  Try the new software tools for yourself. Speed compiling, find bugs
>  proactively, and fine-tune applications for parallel performance.
>  See why Intel Parallel Studio got high marks during beta.
>  http://p.sf.net/sfu/intel-sw-dev
>  _______________________________________________
>  MinGW-users mailing list
>  [hidden email]
>
>  This list observes the Etiquette found at
>  http://www.mingw.org/Mailing_Lists.
>  We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.
>
>  _______________________________________________
>  You may change your MinGW Account Options or unsubscribe at:
>  https://lists.sourceforge.net/lists/listinfo/mingw-users
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: [regex]: Why it's failed to build

DouglasA1
In reply to this post by Jean He
I like to use SciTE.exe sometimes and here is the output of what you have:

>g++ -pedantic -Os regex.cc -o regex
regex.cc:1:17: regex: No such file or directory
regex.cc: In function `int main()':
regex.cc:8: error: `regex' does not name a type
regex.cc:11: error: `r' was not declared in this scope
regex.cc:11: error: `regex_match' was not declared in this scope
>Exit code: 1

That is probably due to my installation still being C:\MinGW\include\c++\3.4.5
I looked for that header in there and is not present. You must have it
then in 4.4?

On 3/17/10, Jean He <[hidden email]> wrote:

>
> Hi all:
>
> I download MinGW with g++ 4.4, and I can't wait to try it.
>
> I write a sample cpp like this:
> #include <regex>
> #include <string>
> #include <iostream>
> using namespace std;
>
> int main()
> {
>  const regex r("[1-9]*x[2-9]+");
>
>  for (string s; getline(cin, s); )
>  {
>  cout << (regex_match(s, r) ? "Yes" : "No") << endl;
>  }
>
>         return 0;
> }
>
> After I build it, some errors are thrown, I don't know if I miss some
> options or...
>
> D:\MinGW_Env\Code>g++ -std=c++0x regex.cpp -o regex.exe
> In file included from
> d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/postypes.h:42,
>                  from
> d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/char_traits.h:42,
>                   from
> d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/string:42,
>                  from
> d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/bitset:49,
>                  from
> d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/regex:43,
>                  from regex.cpp:1:
> d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159:
> error: '::swprintf' has not been declared
> d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166:
> error: '::vswprintf' has not been declared
>
> Can you please help me figure out what's wrong in above process, thank you
> very much in advance.
>
> Thanks,
> Mike
>
> ------------------------------------------------------------------------------
>  Download Intel&#174; Parallel Studio Eval
>  Try the new software tools for yourself. Speed compiling, find bugs
>  proactively, and fine-tune applications for parallel performance.
>  See why Intel Parallel Studio got high marks during beta.
>  http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
>  MinGW-users mailing list
>  [hidden email]
>
>  This list observes the Etiquette found at
>  http://www.mingw.org/Mailing_Lists.
>  We ask that you be polite and do the same.  Disregard for the list
> etiquette may cause your account to be moderated.
>
>  _______________________________________________
>  You may change your MinGW Account Options or unsubscribe at:
>  https://lists.sourceforge.net/lists/listinfo/mingw-users
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: [regex]: Why it's failed to build

Keith Marshall
In reply to this post by Jean He
On Wednesday 17 March 2010 14:03:51 Jean He wrote:
> I download MinGW with g++ 4.4, and I can't wait to try it.

Any particular reason why you chose 4.4 rather than the recently
released 4.5?  (Both have been classified as "experimental").

On Wednesday 17 March 2010 14:33:11 Greg Chicares replied:
> > D:\MinGW_Env\Code>g++ -std=c++0x regex.cpp -o regex.exe
> [...]
> > d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159
> >: error: '::swprintf' has not been declared
>
> This search:
>   http://www.google.com/search?q="'::swprintf' has not been
> declared" suggests that '-std=c++0x' is incompatible with
> swprintf().

To be strictly accurate, it's Microsoft's implementations of
[v]swprintf() which are not compatible with *any* option which
requires ANSI standards compliance, (of which -std=c++0x is just one
example).  This is a known defect, which has been present since
Danny Smith added guards to reject references to these functions in
standards conforming code (from mingwrt-3.15 IIRC), yet GCC
continued to gratuitously assumed them to be declared for any C++
code including the cwchar header, (either explicitly or implicitly),
up until the release of gcc-4.5.0.

This bug will disappear, if you upgrade to the latest release, (which
for the time being, you *must* install in C:\MinGW, (or at the very
least ensure that it is supported by mingwrt and w32api headers
installed there)).

--
Regards,
Keith.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: [regex]: Why it's failed to build

Andy Rushton
In reply to this post by Jean He
Jean He wrote:
>
> After I build it, some errors are thrown, I don't know if I miss some
> options or...
>
>
> d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error:
> '::swprintf' has not been declared
> d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166: error:
> '::vswprintf' has not been declared

FWIW I came across this error some time back and fortunately kept a
record of the fix. I thought it had gone in gcc v4, so maybe this has
crept back in?

Here's the explanation/solution I found:

I had compiler errors in gcc v3.4.5 with the -std=c++0x option
switched on.

 From Mark Cave-Ayland on the MinGW list:

----------------------------------------
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/cwchar:161:error:
`::swprintf' has not been declared
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/cwchar:168:error:
`::vswprintf' has not been declared

After a bit of fiddling, I found that I was able to get my test program
above to compile in ANSI mode by loading include/c++/3.4.5/cwchar and
commenting out the lines containing "using ::swprintf" and "using
::vswprintf".

I think that this related to the fact that the swprintf() and vswprintf()
functions in wchar.h are surrounded by an "#ifndef __STRICT_ANSI__"
declaration; however I am not sure whether or not surrounding the "using"
lines mentioned above with the same declaration is the correct thing to do
in C++.
----------------------------------------

I placed #ifndef __STRICT_ANSI__ switches around the two offending
declarations in include/c++/3.4.5/cwchar and that resolved it.

So, of course you have a different version number, therefore a different
path to the cwchar header.

Andy


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: [regex]: Why it's failed to build

Keith Marshall
On Friday 19 March 2010 09:12:07 Andy Rushton wrote:
> > d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159
> >: error: '::swprintf' has not been declared
> > d:\mingw_env\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166
> >: error: '::vswprintf' has not been declared
>
> FWIW I came across this error some time back and fortunately kept
> a record of the fix. I thought it had gone in gcc v4, so maybe
> this has crept back in?

No.  The issue arose when Danny Smith added, (prematurely[*] IMHO),
guards in mingwrt-3.15+ to forbid references in C99 conforming code
to this pair of functions, because their Microsoft implementations
do not conform to the standard.

[*] As a GCC developer, Danny should have known better.  G++'s cwchar
header gratuitously refers to both of those functions, in any source
file which includes it, regardless of whether the user's code refers
to them, or not.  This was not fixed in GCC, until the recent
release of GCC-4.5.0.

For further follow-up, see:
http://sourceforge.net/tracker/index.php?func=detail&aid=2373234&group_id=2435&atid=102435

Notice that two plausible workarounds were proposed, but there was
never any consensus reached, about applying either patch.

--
Regards,
Keith.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users