* [Powertop] [PATCH 1/2] Fix build with C++11 support enabled
@ 2012-05-13 9:49 Ivan Shapovalov
0 siblings, 0 replies; 2+ messages in thread
From: Ivan Shapovalov @ 2012-05-13 9:49 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 1702 bytes --]
In particular, usage of __DATE__ in main.cpp is now recognized as a
user-defined literal, so an additional whitespace is required separating
the string and __DATE__.
Also, typeof (which was a GNU extension) is now replaced by decltype,
so perf/perf_bundle.cpp has been modified.
The preprocessor is used to tell whether we are compiling in C++11 mode
or not and select the keyword accordingly.
---
src/main.cpp | 2 +-
src/perf/perf_bundle.cpp | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/main.cpp b/src/main.cpp
index e168fa4..433fea6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -80,7 +80,7 @@ static const struct option long_options[] =
static void print_version()
{
- printf(_("Powertop version" POWERTOP_VERSION ", compiled on "__DATE__ "\n"));
+ printf(_("Powertop version" POWERTOP_VERSION ", compiled on " __DATE__ "\n"));
}
static bool set_refresh_timeout()
diff --git a/src/perf/perf_bundle.cpp b/src/perf/perf_bundle.cpp
index fc677f5..38e1e91 100644
--- a/src/perf/perf_bundle.cpp
+++ b/src/perf/perf_bundle.cpp
@@ -38,6 +38,10 @@
#include "../cpu/cpu.h"
+#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
+# define USE_DECLTYPE
+#endif
+
class perf_bundle_event: public perf_event
{
public:
@@ -58,7 +62,11 @@ void perf_bundle_event::handle_event(struct perf_event_header *header, void *coo
buffer = (unsigned char *)malloc(header->size);
memcpy(buffer, header, header->size);
+#ifdef USE_DECLTYPE
+ vector = (decltype(vector))cookie;
+#else
vector = (typeof(vector))cookie;
+#endif
vector->push_back(buffer);
}
--
1.7.10.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Powertop] [PATCH 1/2] Fix build with C++11 support enabled
@ 2012-05-14 17:29 Chris Ferron
0 siblings, 0 replies; 2+ messages in thread
From: Chris Ferron @ 2012-05-14 17:29 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 1876 bytes --]
Thank you for the patch.
-Chris
On 05/13/2012 02:49 AM, Ivan Shapovalov wrote:
> In particular, usage of __DATE__ in main.cpp is now recognized as a
> user-defined literal, so an additional whitespace is required separating
> the string and __DATE__.
>
> Also, typeof (which was a GNU extension) is now replaced by decltype,
> so perf/perf_bundle.cpp has been modified.
> The preprocessor is used to tell whether we are compiling in C++11 mode
> or not and select the keyword accordingly.
> ---
> src/main.cpp | 2 +-
> src/perf/perf_bundle.cpp | 8 ++++++++
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/src/main.cpp b/src/main.cpp
> index e168fa4..433fea6 100644
> --- a/src/main.cpp
> +++ b/src/main.cpp
> @@ -80,7 +80,7 @@ static const struct option long_options[] =
>
> static void print_version()
> {
> - printf(_("Powertop version" POWERTOP_VERSION ", compiled on "__DATE__ "\n"));
> + printf(_("Powertop version" POWERTOP_VERSION ", compiled on " __DATE__ "\n"));
> }
>
> static bool set_refresh_timeout()
> diff --git a/src/perf/perf_bundle.cpp b/src/perf/perf_bundle.cpp
> index fc677f5..38e1e91 100644
> --- a/src/perf/perf_bundle.cpp
> +++ b/src/perf/perf_bundle.cpp
> @@ -38,6 +38,10 @@
>
> #include "../cpu/cpu.h"
>
> +#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus>= 201103L)
> +# define USE_DECLTYPE
> +#endif
> +
> class perf_bundle_event: public perf_event
> {
> public:
> @@ -58,7 +62,11 @@ void perf_bundle_event::handle_event(struct perf_event_header *header, void *coo
> buffer = (unsigned char *)malloc(header->size);
> memcpy(buffer, header, header->size);
>
> +#ifdef USE_DECLTYPE
> + vector = (decltype(vector))cookie;
> +#else
> vector = (typeof(vector))cookie;
> +#endif
> vector->push_back(buffer);
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-05-14 17:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-14 17:29 [Powertop] [PATCH 1/2] Fix build with C++11 support enabled Chris Ferron
-- strict thread matches above, loose matches on Subject: below --
2012-05-13 9:49 Ivan Shapovalov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.