Fixes 2 problems when building the code with gcc on Linux.
) First problem came out when I included the "EWeather.h" to c++ file.

In file included from /usr/local/include/EWeather_Plugins.h:4,
from W1DeviceManagerController.hh:14,
from W1DeviceManagerController.cc:15:
/usr/local/include/EWeather.h:9: error: use of enum ‘EWeather_Type’
without previous declaration
/usr/local/include/EWeather.h:9: error: invalid type in declaration
before ‘;’ token
/usr/local/include/EWeather.h:10: error: use of enum ‘EWeather_Temp’
without previous declaration
/usr/local/include/EWeather.h:10: error: invalid type in declaration
before ‘;’ token
/usr/local/include/EWeather.h:14: error: using typedef-name
‘EWeather_Type’ after ‘enum’
/usr/local/include/EWeather.h:9: error: ‘EWeather_Type’ has a previous
declaration here
/usr/local/include/EWeather.h:35: error: using typedef-name
‘EWeather_Temp’ after ‘enum’
/usr/local/include/EWeather.h:10: error: ‘EWeather_Temp’ has a previous
declaration here

This problem appeared because in EWeather.h there were these 2 typedef
enum lines before the enums itself were defined.
The fix for this one was simply to move these lines couple of lines
lower after the enums were introduced.
typedef enum EWeather_Type EWeather_Type;
typedef enum EWeather_Temp EWeather_Temp;

2) Second problem came from the linker. It failed to find the functions
when tried to link them from the c++ code.
Fix for this is to put the public API function definitions in EWeather.h
and EWeather_Plugins.h to extern "C" block when build with gcc++.

extern"C" {
...
}


>From aca4fe2123a7690eb4b5376b29534b7c42f27580 Mon Sep 17 00:00:00 2001
From: Mika Laitio <[email protected]>
Date: Sat, 12 Mar 2011 20:45:07 +0200
Subject: [PATCH 1/3] enable libeweather usage from c++ code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

I found 2 small problems when building the code with gcc on Linux.
) First problem came out when I included the "EWeather.h" to c++ file.

In file included from /usr/local/include/EWeather_Plugins.h:4,
from W1DeviceManagerController.hh:14,
from W1DeviceManagerController.cc:15:
/usr/local/include/EWeather.h:9: error: use of enum ‘EWeather_Type’
without previous declaration
/usr/local/include/EWeather.h:9: error: invalid type in declaration
before ‘;’ token
/usr/local/include/EWeather.h:10: error: use of enum ‘EWeather_Temp’
without previous declaration
/usr/local/include/EWeather.h:10: error: invalid type in declaration
before ‘;’ token
/usr/local/include/EWeather.h:14: error: using typedef-name
‘EWeather_Type’ after ‘enum’
/usr/local/include/EWeather.h:9: error: ‘EWeather_Type’ has a previous
declaration here
/usr/local/include/EWeather.h:35: error: using typedef-name
‘EWeather_Temp’ after ‘enum’
/usr/local/include/EWeather.h:10: error: ‘EWeather_Temp’ has a previous
declaration here

This problem appeared because in EWeather.h there were these 2 typedef
enum lines before the enums itself were defined.
The fix for this one was simply to move these lines couple of lines
lower after the enums were introduced.
typedef enum EWeather_Type EWeather_Type;
typedef enum EWeather_Temp EWeather_Temp;

2) Second problem came from the linker. It failed to find the functions
when tried to link them from the c++ code.
Fix for this is to put the public API function definitions in EWeather.h
and EWeather_Plugins.h to extern "C" block when build with gcc++.

extern"C" {
...
}

Signed-off-by: Mika Laitio <[email protected]>
---
 src/lib/EWeather.h         |   14 +++++++++++---
 src/lib/EWeather_Plugins.h |    8 ++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/lib/EWeather.h b/src/lib/EWeather.h
index f47089e..d4d4681 100644
--- a/src/lib/EWeather.h
+++ b/src/lib/EWeather.h
@@ -3,12 +3,13 @@
 
 #include <Eina.h>
 
+#ifdef __cplusplus
+       extern"C" {
+#endif
+
 typedef struct EWeather EWeather;
 typedef struct EWeather_Data EWeather_Data;
 
-typedef enum EWeather_Type EWeather_Type;
-typedef enum EWeather_Temp EWeather_Temp;
-
 typedef void (*Update_Cb) (void *data, EWeather *eweather);
 
 enum EWeather_Type
@@ -38,6 +39,9 @@ enum EWeather_Temp
    EWEATHER_TEMP_CELCIUS
 };
 
+typedef enum EWeather_Type EWeather_Type;
+typedef enum EWeather_Temp EWeather_Temp;
+
 EAPI   Eina_Array *    eweather_plugins_list_get(EWeather *eweather);
 EAPI   Eina_Module *   eweather_plugin_search(EWeather *eweather, const char 
*name);
 EAPI   const char *    eweather_plugin_name_get(EWeather *eweather, int i);
@@ -76,4 +80,8 @@ EAPI  void            eweather_callbacks_set(EWeather 
*eweather, Update_Cb update_cb, void
 
 EAPI   int             eweather_utils_celcius_get(int farenheit);
 
+#ifdef __cplusplus
+       }
+#endif
+
 #endif
diff --git a/src/lib/EWeather_Plugins.h b/src/lib/EWeather_Plugins.h
index 28f26e0..14f016a 100644
--- a/src/lib/EWeather_Plugins.h
+++ b/src/lib/EWeather_Plugins.h
@@ -6,6 +6,10 @@
 #include <string.h>
 #include <stdio.h>
 
+#ifdef __cplusplus
+       extern"C" {
+#endif
+
 typedef struct EWeather_Plugin EWeather_Plugin;
 typedef void (*Plugin_Init) (EWeather *eweather);
 typedef void (*Plugin_Shutdown) (EWeather *eweather);
@@ -69,4 +73,8 @@ void eweather_plugin_load(EWeather *eweather);
 EAPI void eweather_plugin_update(EWeather *eweather);
 void eweather_plugin_shutdown(EWeather *eweather);
 
+#ifdef __cplusplus
+       }
+#endif
+
 #endif
-- 
1.7.1

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to