dskvr / opkg

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

libopkg incompatible with C++ (w/ quick fix) #80

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
libopkg's include of "list.h" uses the reserved "new" keyword in the header 
file which excludes compilation within a C++ program even when using extern 
"C".  

The diff patch file below includes the fixes necessary to allow libopkg to be 
used with the g++ C++ compiler in either language mode.  A complete replacement 
list.h is attached. 

--- opkg-0.1.8/libopkg/list.h   2009-11-01 16:44:06.000000000 -0700
+++ opkg-0.1.8-update/libopkg/list.h    2011-07-22 21:44:21.316930569 -0700
@@ -36,37 +36,37 @@
    (ptr)->next = (ptr); (ptr)->prev = (ptr); \
 } while (0)

-static inline void __list_add(struct list_head *new,
+static inline void __list_add(struct list_head *lnew,
                               struct list_head *prev,
                               struct list_head *next) {
-    next->prev = new;
-    new->next = next;
-    new->prev = prev;
-    prev->next = new;
+    next->prev = lnew;
+    lnew->next = next;
+    lnew->prev = prev;
+    prev->next = lnew;
 }

 /**
  * list_add - add a new entry
- * @new: new entry to be added
+ * @lnew: new entry to be added
  * @head: list head to add it after
  *
  * Insert a new entry after the specified head.
  * This is good for implementing stacks.
  */
-static inline void list_add(struct list_head *new, struct list_head *head) {
-    __list_add(new, head, head->next);
+static inline void list_add(struct list_head *lnew, struct list_head *head) {
+    __list_add(lnew, head, head->next);
 }

 /**
  * list_add_tail - add a new entry
- * @new: new entry to be added
+ * @lnew: new entry to be added
  * @head: list head to add it before
  *
  * Insert a new entry before the specified head.
  * This is useful for implementing queues.
  */
-static inline void list_add_tail(struct list_head *new, struct list_head 
*head) {
-    __list_add(new, head->prev, head);
+static inline void list_add_tail(struct list_head *lnew, struct list_head 
*head) {
+    __list_add(lnew, head->prev, head);
 }

@@ -90,8 +90,8 @@
  */
 static inline void list_del(struct list_head *entry) {
     __list_del(entry->prev, entry->next);
-    entry->next = LIST_POISON1;
-    entry->prev = LIST_POISON2;
+    entry->next = (list_head*)LIST_POISON1;
+    entry->prev = (list_head*)LIST_POISON2;
 }

 /**

Original issue reported on code.google.com by scm6...@gmail.com on 23 Jul 2011 at 5:20

GoogleCodeExporter commented 8 years ago
Hasty upload left off the "struct" keyword on list line 93, 94.  Please see 
updated patch / list.h file. 

--- opkg-0.1.8/libopkg/list.h   2009-11-01 16:44:06.000000000 -0700
+++ opkg-0.1.8-cyber/libopkg/list.h 2011-07-22 22:28:33.000000000 -0700
@@ -36,37 +36,37 @@
    (ptr)->next = (ptr); (ptr)->prev = (ptr); \
 } while (0)

-static inline void __list_add(struct list_head *new,
+static inline void __list_add(struct list_head *lnew,
                               struct list_head *prev,
                               struct list_head *next) {
-    next->prev = new;
-    new->next = next;
-    new->prev = prev;
-    prev->next = new;
+    next->prev = lnew;
+    lnew->next = next;
+    lnew->prev = prev;
+    prev->next = lnew;
 }

 /**
  * list_add - add a new entry
- * @new: new entry to be added
+ * @lnew: new entry to be added
  * @head: list head to add it after
  *
  * Insert a new entry after the specified head.
  * This is good for implementing stacks.
  */
-static inline void list_add(struct list_head *new, struct list_head *head) {
-    __list_add(new, head, head->next);
+static inline void list_add(struct list_head *lnew, struct list_head *head) {
+    __list_add(lnew, head, head->next);
 }

 /**
  * list_add_tail - add a new entry
- * @new: new entry to be added
+ * @lnew: new entry to be added
  * @head: list head to add it before
  *
  * Insert a new entry before the specified head.
  * This is useful for implementing queues.
  */
-static inline void list_add_tail(struct list_head *new, struct list_head 
*head) {
-    __list_add(new, head->prev, head);
+static inline void list_add_tail(struct list_head *lnew, struct list_head 
*head) {
+    __list_add(lnew, head->prev, head);
 }

@@ -90,8 +90,8 @@
  */
 static inline void list_del(struct list_head *entry) {
     __list_del(entry->prev, entry->next);
-    entry->next = LIST_POISON1;
-    entry->prev = LIST_POISON2;
+    entry->next = (struct list_head*)LIST_POISON1;
+    entry->prev = (struct list_head*)LIST_POISON2;
 }

 /**

Original comment by scm6...@gmail.com on 23 Jul 2011 at 5:35

Attachments:

GoogleCodeExporter commented 8 years ago
This has already been fixed in r527.

Original comment by graham.g...@gmail.com on 25 Jul 2011 at 12:45