All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Powertop] [PATCH 04/12] fix clang++ compilation errors
@ 2014-08-02 12:19 Magnus Fromreide
  0 siblings, 0 replies; 3+ messages in thread
From: Magnus Fromreide @ 2014-08-02 12:19 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

On Sat, Aug 02, 2014 at 12:54:09PM +0100, Sami Kerola wrote:
> The same error was fixed in multiple files to made clang++ work.
> 
> error: variable length array of non-POD element type 'string' (aka
> 'basic_string<char>')

Stupid question: Why not a vector<string> ?

/MF

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Powertop] [PATCH 04/12] fix clang++ compilation errors
@ 2014-08-02 22:09 Sami Kerola
  0 siblings, 0 replies; 3+ messages in thread
From: Sami Kerola @ 2014-08-02 22:09 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

On 2 August 2014 13:19, Magnus Fromreide <magfr(a)lysator.liu.se> wrote:
> On Sat, Aug 02, 2014 at 12:54:09PM +0100, Sami Kerola wrote:
>> The same error was fixed in multiple files to made clang++ work.
>>
>> error: variable length array of non-POD element type 'string' (aka
>> 'basic_string<char>')
>
> Stupid question: Why not a vector<string> ?

The clang++ did not like them, the error I got is

tuning/tuning.cpp:293:26: error: no viable conversion from
'std::vector<string>' to 'string *'
      (aka 'basic_string<char> *')
        report.add_table(tuned_data, &tune_table_css);

and I don't know how to make vectors work in that case. Of course part
of the problem is that my C++ skill is in beginner level zero, and I
might be doing something stupid. Assuming the later a hint how to make
that code better would be nice.

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Powertop] [PATCH 04/12] fix clang++ compilation errors
@ 2014-08-02 11:54 Sami Kerola
  0 siblings, 0 replies; 3+ messages in thread
From: Sami Kerola @ 2014-08-02 11:54 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 10266 bytes --]

The same error was fixed in multiple files to made clang++ work.

error: variable length array of non-POD element type 'string' (aka
'basic_string<char>')

Signed-off-by: Sami Kerola <kerolasa(a)iki.fi>
---
 src/cpu/cpu.cpp            | 18 ++++++++++++------
 src/devices/ahci.cpp       |  3 ++-
 src/devices/device.cpp     |  6 ++++--
 src/devlist.cpp            |  3 ++-
 src/process/do_process.cpp |  9 ++++++---
 src/report/report.cpp      |  3 ++-
 src/tuning/tuning.cpp      | 10 ++++++----
 7 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index dbca20c..4e040c1 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -479,12 +479,12 @@ void report_display_cpu_cstates(void)
 		/* Tables for PKG, CORE, CPU */
 		pkg_tbl_size.cols=2;
 		pkg_tbl_size.rows= ((cstates_num+1)-LEVEL_HEADER)+1;
-		string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
+		string *pkg_data = new string[pkg_tbl_size.cols * pkg_tbl_size.rows];
 
 		core_tbl_size.cols=2;
 		core_tbl_size.rows=(cstates_num *_package->children.size())
 				+ _package->children.size();
-		string core_data[core_tbl_size.cols * core_tbl_size.rows];
+		string *core_data = new string[core_tbl_size.cols * core_tbl_size.rows];
 		int num_cpus=0, num_cores=0;
 
 		for (core = 0; core < _package->children.size(); core++) {
@@ -506,7 +506,7 @@ void report_display_cpu_cstates(void)
 		cpu_tbl_size.cols=(2 * (num_cpus / num_cores)) + 1;
 		cpu_tbl_size.rows = ((cstates_num+1-LEVEL_HEADER) * _package->children.size())
 				+ _package->children.size();
-		string cpu_data[cpu_tbl_size.cols * cpu_tbl_size.rows];
+		string *cpu_data = new string[cpu_tbl_size.cols * cpu_tbl_size.rows];
 
 		for (core = 0; core < _package->children.size(); core++) {
 			cpu_data[idx3]="&nbsp;";
@@ -633,6 +633,9 @@ void report_display_cpu_cstates(void)
 		init_cpu_table_attr(&std_table_css, title+1, cpu_tbl_size.rows,
 				cpu_tbl_size.cols);
 		report.add_table(cpu_data, &std_table_css);
+		delete [] pkg_data;
+		delete [] core_data;
+		delete [] cpu_data;
 	}
 	report.end_div();
 }
@@ -688,11 +691,11 @@ void report_display_cpu_pstates(void)
 		/*  Tables for PKG, CORE, CPU */
 		pkg_tbl_size.cols=2;
 		pkg_tbl_size.rows=((pstates_num+1)-LEVEL_HEADER)+2;
-		string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
+		string *pkg_data = new string[pkg_tbl_size.cols * pkg_tbl_size.rows];
 
 		core_tbl_size.cols=2;
 		core_tbl_size.rows=((pstates_num+2) *_package->children.size());
-		string core_data[core_tbl_size.cols * core_tbl_size.rows];
+		string *core_data = new string[core_tbl_size.cols * core_tbl_size.rows];
 
 		/* PKG */
 		num_cpus=0;
@@ -717,7 +720,7 @@ void report_display_cpu_pstates(void)
 		cpu_tbl_size.cols= (num_cpus/ num_cores) + 1;
 		cpu_tbl_size.rows= (pstates_num+2) * _package->children.size()
 				+ _package->children.size();
-		string cpu_data[cpu_tbl_size.cols * cpu_tbl_size.rows];
+		string *cpu_data = new string[cpu_tbl_size.cols * cpu_tbl_size.rows];
 
 		/* Core */
 		for (core = 0; core < _package->children.size(); core++) {
@@ -818,6 +821,9 @@ void report_display_cpu_pstates(void)
 		init_cpu_table_attr(&std_table_css, title,
 				cpu_tbl_size.rows, cpu_tbl_size.cols);
 		report.add_table(cpu_data, &std_table_css);
+		delete [] pkg_data;
+		delete [] core_data;
+		delete [] cpu_data;
 	}
 	report.end_div();
 }
diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp
index 3b4627a..a0891ae 100644
--- a/src/devices/ahci.cpp
+++ b/src/devices/ahci.cpp
@@ -382,7 +382,7 @@ void ahci_create_device_stats_table(void)
 
 
 	/* Set array of data in row Major order */
-	string ahci_data[cols * rows];
+	string *ahci_data = new string[cols * rows];
 	ahci_data[0]=__("Link");
 	ahci_data[1]=__("Active");
 	ahci_data[2]=__("Partial");
@@ -396,6 +396,7 @@ void ahci_create_device_stats_table(void)
 	report.add_title(&title_attr, __("AHCI ALPM Residency Statistics"));
 	report.add_table(ahci_data, &std_table_css);
 	report.end_div();
+	delete [] ahci_data;
 }
 
 void ahci::report_device_stats(string *ahci_data, int idx)
diff --git a/src/devices/device.cpp b/src/devices/device.cpp
index da595a8..b4765ef 100644
--- a/src/devices/device.cpp
+++ b/src/devices/device.cpp
@@ -247,7 +247,7 @@ void show_report_devices(void)
 
 	/* Device Summary */
 	int summary_size=2;
-        string summary[summary_size];
+	string *summary = new string[summary_size];
 	pw = global_joules_consumed();
 	char buf[32];
 	if (pw > 0.0001) {
@@ -263,9 +263,10 @@ void show_report_devices(void)
 		summary[1].append(" W");
 		report.add_summary_list(summary, summary_size);
 	}
+	delete [] summary;
 
         /* Set array of data in row Major order */
-	string device_data[cols * rows];
+	string *device_data = new string[cols * rows];
 	device_data[0]= __("Usage");
 	device_data[1]= __("Device Name");
 	if (show_power)
@@ -308,6 +309,7 @@ void show_report_devices(void)
 	/* Report Output */
 	report.add_title(&title_attr, __("Device Power Report"));
 	report.add_table(device_data, &std_table_css);
+	delete [] device_data;
 }
 
 
diff --git a/src/devlist.cpp b/src/devlist.cpp
index 21b4c1c..20fe5da 100644
--- a/src/devlist.cpp
+++ b/src/devlist.cpp
@@ -326,7 +326,7 @@ void report_show_open_devices(void)
 	init_title_attr(&title_attr);
 
 	/* Set array of data in row Major order */
-	string process_data[cols * rows];
+	string *process_data = new string[cols * rows];
 
 	sort(target->begin(), target->end(), devlist_sort);
 	process_data[0]=__("Process");
@@ -348,5 +348,6 @@ void report_show_open_devices(void)
 	/* No div attribute here inherits from device power report */
 	report.add_title(&title_attr, __("Process Device Activity"));
 	report.add_table(process_data, &std_table_css);
+	delete [] process_data;
 	report.end_div();
 }
diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
index f7f9765..15115c3 100644
--- a/src/process/do_process.cpp
+++ b/src/process/do_process.cpp
@@ -918,7 +918,7 @@ void report_process_update_display(void)
 	init_title_attr(&title_attr);
 
 	/* Set array of data in row Major order */
-	string  software_data[cols * rows];
+	string *software_data = new string[cols * rows];
 	software_data[0]=__("Usage");
 	software_data[1]=__("Wakeups/s");
 	software_data[2]=__("GPU ops/s");
@@ -1013,6 +1013,7 @@ void report_process_update_display(void)
 	report.add_title(&title_attr, __("Overview of Software Power Consumers"));
 	report.add_table(software_data, &std_table_css);
         report.end_div();
+	delete [] software_data;
 }
 
 void report_summary(void)
@@ -1048,7 +1049,7 @@ void report_summary(void)
 
 	/* Set array for summary */
 	int summary_size =12;
-	string summary[summary_size];
+	string *summary = new string [summary_size];
 	summary[0]=__("Target:");
 	summary[1]=__("1 units/s");
 	summary[2]=__("System: ");
@@ -1068,7 +1069,7 @@ void report_summary(void)
 	summary[11].append(__(" ops/s"));
 
 	/* Set array of data in row Major order */
-	string summary_data[cols * (rows+1)];
+	string *summary_data = new string[cols * (rows+1)];
 	summary_data[0]=__("Usage");
 	summary_data[1]=__("Events/s");
 	summary_data[2]=__("Category");
@@ -1134,6 +1135,8 @@ void report_summary(void)
 	report.add_title(&title_attr, __("Top 10 Power Consumers"));
 	report.add_table(summary_data, &std_table_css);
 	report.end_div();
+	delete [] summary;
+	delete [] summary_data;
 }
 
 
diff --git a/src/report/report.cpp b/src/report/report.cpp
index d55531e..981e984 100644
--- a/src/report/report.cpp
+++ b/src/report/report.cpp
@@ -115,7 +115,7 @@ static void system_info(void)
         init_title_attr(&title_attr);
 
 	/* Set array of data in row Major order */
-	string system_data[sys_table.rows * sys_table.cols];
+	string *system_data = new string[sys_table.rows * sys_table.cols];
 	system_data[0]=__("PowerTOP Version");
 	system_data[1]=POWERTOP_VERSION;
 
@@ -159,6 +159,7 @@ static void system_info(void)
 	report.end_div();
 	report.end_header();
 	report.add_navigation();
+	delete [] system_data;
 }
 
 void init_report_output(char *filename_str, int iterations)
diff --git a/src/tuning/tuning.cpp b/src/tuning/tuning.cpp
index 6367a20..85b80ac 100644
--- a/src/tuning/tuning.cpp
+++ b/src/tuning/tuning.cpp
@@ -230,7 +230,7 @@ void report_show_tunables(void)
 		init_tune_table_attr(&tune_table_css, rows, cols);
 
 		/* Set array of data in row Major order */
-		string tunable_data[cols * rows];
+		string *tunable_data = new string[cols * rows];
 
 		tunable_data[0]=__("Description");
 		tunable_data[1]=__("Script");
@@ -249,6 +249,7 @@ void report_show_tunables(void)
 		/* Report Output */
 		report.add_title(&title_attr,__("Software Settings in Need of Tuning"));
 		report.add_table(tunable_data, &tune_table_css);
+		delete [] tunable_data;
 	}
 
 	/* Second Table */
@@ -258,7 +259,7 @@ void report_show_tunables(void)
 	init_tune_table_attr(&tune_table_css, rows, cols);
 
 	/* Set array of data in row Major order */
-	string untunable_data[rows];
+	string *untunable_data = new string[rows];
 	untunable_data[0]=__("Description");
 
 	for (i = 0; i < all_untunables.size(); i++)
@@ -267,6 +268,7 @@ void report_show_tunables(void)
 	/* Report Output */
 	report.add_title(&title_attr,__("Untunable Software Issues"));
 	report.add_table(untunable_data, &tune_table_css);
+	delete [] untunable_data;
 
 	/* Third Table */
 	/* Set Table attributes, rows, and cols */
@@ -275,7 +277,7 @@ void report_show_tunables(void)
 	init_std_table_attr(&tune_table_css, rows, cols);
 
 	/* Set array of data in row Major order */
-	string tuned_data[rows];
+	string *tuned_data = new string[rows];
 	tuned_data[0]=__("Description");
 	idx=cols;
 	for (i = 0; i < all_tunables.size(); i++) {
@@ -291,7 +293,7 @@ void report_show_tunables(void)
 	report.add_title(&title_attr,__("Optimal Tuned Software Settings"));
         report.add_table(tuned_data, &tune_table_css);
         report.end_div();
-
+	delete [] tuned_data;
 }
 
 void clear_tuning()
-- 
2.0.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-02 22:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-02 12:19 [Powertop] [PATCH 04/12] fix clang++ compilation errors Magnus Fromreide
  -- strict thread matches above, loose matches on Subject: below --
2014-08-02 22:09 Sami Kerola
2014-08-02 11:54 Sami Kerola

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.