boriisaac / google-breakpad

Automatically exported from code.google.com/p/google-breakpad
0 stars 0 forks source link

Compiling Linux example does not work with -std=c++0x #481

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Compiling the Linux example from the Wiki 
(http://code.google.com/p/google-breakpad/wiki/LinuxStarterGuide) does not work 
with -std=c++0x enabled:

$ g++ -std=c++0x -c foo.cpp  -I../google-breakpad/src/
In file included from 
../google-breakpad/src/client/linux/minidump_writer/minidump_writer.h:39,
                 from ../google-breakpad/src/client/linux/handler/exception_handler.h:45,
                 from foo.cpp:1:
../google-breakpad/src/client/linux/minidump_writer/linux_dumper.h:55: error: 
ISO C++ forbids declaration of ‘typeof’ with no type
../google-breakpad/src/client/linux/minidump_writer/linux_dumper.h:55: error: 
typedef ‘google_breakpad::typeof’ is initialized (use decltype instead)
../google-breakpad/src/client/linux/minidump_writer/linux_dumper.h:100: error: 
‘debugreg_t’ does not name a type

$ g++ --version
g++-4.4.real (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3

Original issue reported on code.google.com by christia...@gmail.com on 23 May 2012 at 1:54

GoogleCodeExporter commented 9 years ago
I have the same problem.

Original comment by qbowa...@gmail.com on 29 May 2012 at 4:14

GoogleCodeExporter commented 9 years ago
Do we have a solution to this??

Original comment by muthukum...@gmail.com on 5 Jun 2012 at 12:02

GoogleCodeExporter commented 9 years ago
Replacing the typeof line with something like this seems to work (for the test 
code, breakpad itself obviously no longer compiles):

typedef std::remove_reference<decltype(((struct user*) 
0)->u_debugreg[0])>::type debugreg_t;

The problem then is how to properly detect typeof/decltype availability at 
compile time.

Original comment by christia...@gmail.com on 5 Jun 2012 at 2:53

GoogleCodeExporter commented 9 years ago
The following workaround works for me, though I'm not sure how reliable it is 
to just check the value of __cplusplus.

#if __cplusplus > 199711L
#include <type_traits>
#endif

...

#if __cplusplus > 199711L
typedef std::remove_reference<
    decltype(((struct user*) 0)->u_debugreg[0])
  >::type debugreg_t;
#else
 typedef typeof(((struct user*) 0)->u_debugreg[0]) debugreg_t;
 #endif

Original comment by nshutchi...@gmail.com on 5 Jul 2012 at 2:08

GoogleCodeExporter commented 9 years ago
Another workaround is to compile with "-std=gnu++0x", which enables typeof as 
well.

Original comment by christia...@gmail.com on 6 Jul 2012 at 3:55

GoogleCodeExporter commented 9 years ago
I am using g++ 3.4.4 and having the same issue. Is there any solution for this 
problem ?

Original comment by jain.she...@gmail.com on 28 Jan 2013 at 10:14

GoogleCodeExporter commented 9 years ago
Issue 563 has been merged into this issue.

Original comment by wfh@chromium.org on 24 Apr 2014 at 3:34

GoogleCodeExporter commented 9 years ago
Issue 586 has been merged into this issue.

Original comment by ted.mielczarek on 5 May 2014 at 7:00

GoogleCodeExporter commented 9 years ago
Patch which replaces typeof() with a wrapper that uses decltype<T> and 
std::remove_reference<T>() under C++11.

This also addresses the issue of spaces between string literals and identifiers.

From our fork at 
https://github.com/Mendeley/breakpad/commit/17473504d4d1ee53a1e3e4f3ca5dc54671eb
258b

Original comment by robertkn...@gmail.com on 22 Jul 2014 at 2:27

Attachments:

GoogleCodeExporter commented 9 years ago
something like #define typeof __typeof__ should work too

Original comment by iiv...@productengine.com on 16 Nov 2014 at 10:46

GoogleCodeExporter commented 9 years ago
I uploaded a patch using __typeof__

https://breakpad.appspot.com/7824002/

Original comment by b152fee4...@gmail.com on 22 Mar 2015 at 3:40