Boost Serialization: undefined reference to `__assert'
Hello everyone
Today, I just happened to download the latest version of cygwin, including
gcc 3.4.4. While a simple hello world works perfectly fine, trying to
compile this code using a statically linked libserialization.a results in
dozens of linker errors, all stating "undefined reference to `__assert'".
#include
Sounds to me a confusion between not using NDEBUG during compilation and not linking with debug libraries.
Robert Ramey
"Kesseli Pascal"
Hi everyone Please have a look at the following code: 1: const regex REPORT_HEADER("^[^()]+((?:\\([^()]*\\)){4,})$"); 2: const regex REPORT_DATA_ITEM("\\(([^()]*?)\\)(.*)"); 3: string headerLine = "P.01(1090618220000)(0008)(15)(3)(1.5.0)(kW)(5.5.0)(kvar)(8.5.0)(kvar)"; 4: smatch match; 5: if(regex_match(headerLine, match, REPORT_HEADER)) { 6: regex_match(lexical_cast<string>(match[1]), match, REPORT_DATA_ITEM); 7: clog << match[1] << endl; 8: regex_match(lexical_cast<string>(match[2]), match, REPORT_DATA_ITEM); 9: clog << match[1] << endl; 10: regex_match(lexical_cast<string>(match[2]), match, REPORT_DATA_ITEM); 11: clog << match[1] << endl; 12: regex_match(lexical_cast<string>(match[2]), match, REPORT_DATA_ITEM); 13: unsigned int numberOfEntries = lexical_cast<unsigned int>(match[1]); 14: string tmp; 15: for(unsigned int i = 0; i < numberOfEntries; ++i) { 16: tmp = match[2]; 17: clog << "1: " << tmp << endl; 18: if(regex_match(tmp, match, REPORT_DATA_ITEM)) { 19: clog << "2: " << match[1] << endl; 20: tmp = match[2]; 21: clog << "3: " << tmp << endl; 22: if(regex_match(tmp, match, REPORT_DATA_ITEM)) { 23: clog << "4: " << match[1] << endl; 24: } 25: } 26: } 27: } Important is actually only the trailing for loop. Running the code as it reads above, the output is as expected: 1090618220000 0008 15 1: (1.5.0)(kW)(5.5.0)(kvar)(8.5.0)(kvar) 2: 1.5.0 3: (kW)(5.5.0)(kvar)(8.5.0)(kvar) 4: kW 1: (5.5.0)(kvar)(8.5.0)(kvar) 2: 5.5.0 3: (kvar)(8.5.0)(kvar) 4: kvar 1: (8.5.0)(kvar) 2: 8.5.0 3: (kvar) 4: kvar However, changing line 18 to: if(regex_match(lexical_cast<string>(match[2]), match, REPORT_DATA_ITEM)) { and thus eliminating the temporary variable tmp, results in the following output: kW kvar 1090618220000 0008 15 1: (1.5.0)(kW)(5.5.0)(kvar)(8.5.0)(kvar) 1: 1: What might be the problem here? Am I misusing the match_results class in some way? Thanks for any help and best regards Pascal
Pascal Kesseli wrote: Sent: Friday, July 31, 2009 6:40 AM
However, changing line 18 to: if(regex_match(lexical_cast<string>(match[2]), match,
REPORT_DATA_ITEM)) {
and thus eliminating the temporary variable tmp, results in the
following
output:
kW kvar 1090618220000 0008 15 1: (1.5.0)(kW)(5.5.0)(kvar)(8.5.0)(kvar) 1: 1:
What might be the problem here? Am I misusing the match_results class in some way?
Thanks for any help and best regards Pascal
match_results stores iterators into the original string. The string returned from lexical_cast goes out of scope as soon as regex_match returns, therefore invalidating the iterators in match_results. HTH Andrew
participants (4)
-
Andrew Holden
-
Kesseli Pascal
-
Pascal Kesseli
-
Robert Ramey