Skip to contentSkip to conversation

Minor C++11 compilation fix for rte_pci.h

PATCH In review Stefan Puiu 4 participants 9 messages Feb 11, 2015 – Feb 24, 2015 5 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Minor C++11 compilation fix for rte_pci.h

In C++11 concatenated string literals need to have a space in between. clang 3.4 reports this as an error (and IIRC also gcc-4.8):

dpdk/include/rte_pci.h:96:26: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]

---
 lib/librte_eal/common/include/rte_pci.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/lib/librte_eal/common/include/rte_pci.h
index 66ed793..12ae5a7 100644

lib/librte_eal/common/include/rte_pci.h +0 -0
@@ -93,10 +93,10 @@ extern struct pci_device_list pci_device_list;

/**< Global list of PCI devices.
#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"

/** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
-#define PCI_PRI_FMT "%.4"PRIx16":%.2"PRIx8":%.2"PRIx8".%"PRIx8 +#define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8

/** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
-#define PCI_SHORT_PRI_FMT "%.2"PRIx8":%.2"PRIx8".%"PRIx8 +#define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8

/** Nb. of values in PCI device identifier format string. */ #define PCI_FMT_NVAL 4

Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): CACKs7VAXEvPy1qJi5nNTwO_gQcHifxcu1wBWo0Lqr_hZRj=iBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#2 lore raw
Quoted 6 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stefan Puiu
Sent: Wednesday, February 11, 2015 8:51 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH] Minor C++11 compilation fix for rte_pci.h

Quoted 6 lines

In C++11 concatenated string literals need to have a space in between. clang 3.4 reports this as an error (and IIRC also gcc-4.8):

dpdk/include/rte_pci.h:96:26: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined- literal]

Hi Stefan,

That concatenated string literal with PRI* is used in 65 files in the DPDK source. Is that the only compilation error that you got?

John

A message that is not in the archive (sent off-list or not yet received): B27915DBBA3421428155699D51E4CFE2EC2000-kPTMFJFq+rELt2AQoY/[email protected]

#4 lore raw
Quoted 13 lines · John
Quoted 6 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stefan Puiu
Sent: Wednesday, February 11, 2015 8:51 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH] Minor C++11 compilation fix for rte_pci.h

Quoted 6 lines

In C++11 concatenated string literals need to have a space in between. clang 3.4 reports this as an error (and IIRC also gcc-4.8):

dpdk/include/rte_pci.h:96:26: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined- literal]

Quoted 5 lines

Hi Stefan,

That concatenated string literal with PRI* is used in 65 files in the DPDK source. Is that the only compilation error that you got?

John

It should only be a problem in header files. The C files for DPDK source are always to be compiled up with a C compiler - only the headers get included in application C++ code.

/Bruce

#5 lore raw
Quoted 16 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Friday, February 13, 2015 10:18 AM
To: Mcnamara, John
Cc: Stefan Puiu; [email protected]
Subject: Re: [dpdk-dev] [PATCH] Minor C++11 compilation fix for rte_pci.h

Quoted 9 lines
Quoted 7 lines

In C++11 concatenated string literals need to have a space in between. clang 3.4 reports this as an error (and IIRC also gcc-4.8):

dpdk/include/rte_pci.h:96:26: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined- literal]

Quoted 9 lines
Quoted 1 line

That concatenated string literal with PRI* is used in 65 files in the

DPDK source. Is that the only compilation error that you got?

Quoted 2 lines

John

It should only be a problem in header files. The C files for DPDK source are always to be compiled up with a C compiler - only the headers get included in application C++ code.

Hi,

In that case it only occurs in 3 header files. I guess that patch should be extended to include those as well:

    $ find lib  -name \*.h | xargs grep -l '"PRI'
    lib/librte_vhost/vhost-net-cdev.h
    lib/librte_eal/common/include/rte_pci.h
    lib/librte_mempool/rte_mempool.h

John.

A message that is not in the archive (sent off-list or not yet received): B27915DBBA3421428155699D51E4CFE2EC22A5-kPTMFJFq+rELt2AQoY/[email protected]

#7 lore raw

Hi and thanks for reviewing,

I seem to have somehow missed the email for this one and thought it got lost. Sorry.

Quoted 26 lines · John
Quoted 16 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Friday, February 13, 2015 10:18 AM
To: Mcnamara, John
Cc: Stefan Puiu; [email protected]
Subject: Re: [dpdk-dev] [PATCH] Minor C++11 compilation fix for rte_pci.h

Quoted 9 lines
Quoted 7 lines

In C++11 concatenated string literals need to have a space in between. clang 3.4 reports this as an error (and IIRC also gcc-4.8):

dpdk/include/rte_pci.h:96:26: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined- literal]

Quoted 9 lines
Quoted 1 line

That concatenated string literal with PRI* is used in 65 files in the

DPDK source. Is that the only compilation error that you got?

Quoted 2 lines

John

It should only be a problem in header files. The C files for DPDK source are always to be compiled up with a C compiler - only the headers get included in application C++ code.

Quoted 8 lines

Hi,

In that case it only occurs in 3 header files. I guess that patch should be extended to include those as well:

    $ find lib  -name \*.h | xargs grep -l '"PRI'
    lib/librte_vhost/vhost-net-cdev.h
    lib/librte_eal/common/include/rte_pci.h
    lib/librte_mempool/rte_mempool.h

Makes sense. Bruce is right, I'm only including headers from C++, the library is compiled using C.

It seems I didn't hit the rte_mempool.h because (at least in 1.8.0) that the usage of PRI* is under #ifdef RTE_LIBRTE_MEMPOOL_DEBUG. It's very likely I didn't need the first file in the list.

Anyway, I'll send a new version.

Quoted 7 lines

John.
--

#8 lore raw

PATCH 1/2 rte_pci.h: Fix C++11 compilation

In reply to a message not in the archive

In C++11 concatenated string literals need to have a
space in between. Found with clang++-3.4, IIRC g++-4.8 also complains about this.

Sample error message:
dpdk/include/rte_pci.h:96:26: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]

---
 lib/librte_eal/common/include/rte_pci.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/common/include/rte_pci.h +2 -2
index 66ed793..12ae5a7 100644
@@ -93,10 +93,10 @@ extern struct pci_device_list pci_device_list; /**< Global list of PCI devices.
 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
 
 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
-#define PCI_PRI_FMT "%.4"PRIx16":%.2"PRIx8":%.2"PRIx8".%"PRIx8
+#define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
 
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
-#define PCI_SHORT_PRI_FMT "%.2"PRIx8":%.2"PRIx8".%"PRIx8
+#define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
 
 /** Nb. of values in PCI device identifier format string. */
 #define PCI_FMT_NVAL 4
Signature · 1 line
1.7.9.5
Quoted 1 line

From 12a4d5def7d35bc790b55da01bb9fc0b11e09340 Mon Sep 17 00:00:00 2001

From: Stefan Puiu <[email protected]>
Date: Fri, 20 Feb 2015 14:47:58 +0200
Subject: [PATCH 2/2] Headers: more C++11 compilation fixes

Fixed two more places where non-C++11 string concatenation is used. Spotted by John McNamara.

---
 lib/librte_mempool/rte_mempool.h  |    8 ++++----
 lib/librte_vhost/vhost-net-cdev.h |    4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
lib/librte_mempool/rte_mempool.h +4 -4
index 3314651..48e9972 100644
@@ -342,7 +342,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE1) {
 				rte_log_set_history(0);
 				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%"PRIx64"\n",
+					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
 					obj, mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (put)\n");
 			}
@@ -352,7 +352,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
 				rte_log_set_history(0);
 				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%"PRIx64"\n",
+					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
 					obj, mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (get)\n");
 			}
@@ -363,7 +363,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
 			    cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
 				rte_log_set_history(0);
 				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%"PRIx64"\n",
+					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
 					obj, mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (audit)\n");
 			}
@@ -372,7 +372,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
 		if (cookie != RTE_MEMPOOL_TRAILER_COOKIE) {
 			rte_log_set_history(0);
 			RTE_LOG(CRIT, MEMPOOL,
-				"obj=%p, mempool=%p, cookie=%"PRIx64"\n",
+				"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
 				obj, mp, cookie);
 			rte_panic("MEMPOOL: bad trailer cookie\n");
 		}
lib/librte_vhost/vhost-net-cdev.h +2 -2
index 03a5c57..37e4ad2 100644
@@ -55,9 +55,9 @@
 	char packet[VHOST_MAX_PRINT_BUFF]; \
 	\
 	if ((header)) \
-		snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%"PRIu64") Header size %d: ", (device->device_fh), (size)); \
+		snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%" PRIu64 ") Header size %d: ", (device->device_fh), (size)); \
 	else \
-		snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%"PRIu64") Packet size %d: ", (device->device_fh), (size)); \
+		snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%" PRIu64 ") Packet size %d: ", (device->device_fh), (size)); \
 	for (index = 0; index < (size); index++) { \
 		snprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), \
 			"%02hhx ", pkt_addr[index]); \
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH 1/2 rte_pci.h: Fix C++11 compilation

In reply to a message not in the archive

From: Stefan Puiu <[email protected]>

In C++11 concatenated string literals need to have a
space in between. Found with clang++-3.4, IIRC g++-4.8 also complains about this.

Sample error message:
dpdk/include/rte_pci.h:96:26: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]

---
 lib/librte_eal/common/include/rte_pci.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/common/include/rte_pci.h +2 -2
index 66ed793..12ae5a7 100644
@@ -93,10 +93,10 @@ extern struct pci_device_list pci_device_list; /**< Global list of PCI devices.
 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
 
 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
-#define PCI_PRI_FMT "%.4"PRIx16":%.2"PRIx8":%.2"PRIx8".%"PRIx8
+#define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
 
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
-#define PCI_SHORT_PRI_FMT "%.2"PRIx8":%.2"PRIx8".%"PRIx8
+#define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
 
 /** Nb. of values in PCI device identifier format string. */
 #define PCI_FMT_NVAL 4
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1424438606-1130-1-git-send-email-stefan.puiu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#11 lore raw

PATCH 2/2 Headers: more C++11 compilation fixes

Fixed two more places where non-C++11 string concatenation is used. Spotted by John McNamara.

---
 lib/librte_mempool/rte_mempool.h  |    8 ++++----
 lib/librte_vhost/vhost-net-cdev.h |    4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
lib/librte_mempool/rte_mempool.h +4 -4
index 3314651..48e9972 100644
@@ -342,7 +342,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE1) {
 				rte_log_set_history(0);
 				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%"PRIx64"\n",
+					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
 					obj, mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (put)\n");
 			}
@@ -352,7 +352,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
 				rte_log_set_history(0);
 				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%"PRIx64"\n",
+					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
 					obj, mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (get)\n");
 			}
@@ -363,7 +363,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
 			    cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
 				rte_log_set_history(0);
 				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%"PRIx64"\n",
+					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
 					obj, mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (audit)\n");
 			}
@@ -372,7 +372,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
 		if (cookie != RTE_MEMPOOL_TRAILER_COOKIE) {
 			rte_log_set_history(0);
 			RTE_LOG(CRIT, MEMPOOL,
-				"obj=%p, mempool=%p, cookie=%"PRIx64"\n",
+				"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
 				obj, mp, cookie);
 			rte_panic("MEMPOOL: bad trailer cookie\n");
 		}
lib/librte_vhost/vhost-net-cdev.h +2 -2
index 03a5c57..37e4ad2 100644
@@ -55,9 +55,9 @@
 	char packet[VHOST_MAX_PRINT_BUFF]; \
 	\
 	if ((header)) \
-		snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%"PRIu64") Header size %d: ", (device->device_fh), (size)); \
+		snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%" PRIu64 ") Header size %d: ", (device->device_fh), (size)); \
 	else \
-		snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%"PRIu64") Packet size %d: ", (device->device_fh), (size)); \
+		snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%" PRIu64 ") Packet size %d: ", (device->device_fh), (size)); \
 	for (index = 0; index < (size); index++) { \
 		snprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), \
 			"%02hhx ", pkt_addr[index]); \
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1424438606-1130-2-git-send-email-stefan.puiu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#13 lore raw

Re: [PATCH 2/2] Headers: more C++11 compilation fixes

2015-02-20 15:23, Stefan Puiu:

Quoted 4 lines

Fixed two more places where non-C++11 string concatenation is used. Spotted by John McNamara.

Both patches merged and applied, thanks.