This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Problems with "global".. on compile-time (with my

Discussion of Eggdrop's code and module programming in C.
Post Reply
m
makam
Voice
Posts: 15
Joined: Thu Jul 08, 2004 1:16 am
Location: Montevideo, Uruguay
Contact:

Problems with "global".. on compile-time (with my

Post by makam »

Hi, i'm written my C module + xml + curl librarys

And my problems show up (it looks like) when i include the curl.h
in my module. :evil:

My main file is: htlive.c

and some part of the code is:

Code: Select all

....
#include <string.h>

#undef global
#include "src/mod/module.h"
#include "src/users.h"
#include "src/chan.h"
#include "channels.mod/channels.h"
#include "htlive.h"

static Function *global = NULL, *channels_funcs = NULL,*server_funcs = NULL;

static char htlive_login[32];		// (Read htlive.conf)
static char htlive_passwd[32];		// (Read htlive.conf)

#include "curl.c"
....
In curl.c is where i include curl's headers...

Code: Select all

#include <curl/curl.h>
#include <curl/easy.h>

Well, the problems is when i type "make"

Code: Select all

gcc -pipe -fPIC -g -O2 -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H  `xml2-config --cflags`  `curl-config --cflags`  -DMAKING_MODS \
-c .././htlive.mod/htlive.c -Ixml 
En el fichero incluído de ../htlive.mod/curl.c:5,
                 de ../htlive.mod/htlive.c:71:
/usr/include/curl/curl.h:772: error de decodificación antes de "global"
(Yes, its in spanish..)
The translation is something like this:
error de decodificación antes de "global" --> parsing error before "global"

I was thinking a lot, but any solution found.
Perhaps, the problems is that i dont know really why this
"#undef global" is there... :oops:



...any idea?

Thanks.
Last edited by makam on Thu Aug 11, 2005 8:09 am, edited 1 time in total.
--
Web: http://www.makam.org/
Chans: #Uruguay,#Hattricklatino@UnderNet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

remove that #undef or enclose it in #ifdef,#endif
m
makam
Voice
Posts: 15
Joined: Thu Jul 08, 2004 1:16 am
Location: Montevideo, Uruguay
Contact:

:(

Post by makam »

Doesnt work! :cry:

The same error.
Perhaps, the error is not the "#undef global", because i removed it and
enclose it, like u said.

hmhm.... Function *global? :? :?

Make log -> http://hteggviewer.makam.org/errors/make.log

The files:
http://hteggviewer.makam.org/errors/curl.c
http://hteggviewer.makam.org/errors/htlive.c

Rest of the files:
http://hteggviewer.makam.org/errors/



More ideas?
--
Web: http://www.makam.org/
Chans: #Uruguay,#Hattricklatino@UnderNet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

of course, eggdrop exports the global array of function/variable pointers which are available for module use; try to fix curl not to interfere with that (or fix eggdrop to use another name, however that would be more dificult)
G
Galadhrim
Op
Posts: 123
Joined: Fri Apr 11, 2003 8:38 am
Location: Netherlands, Enschede

Post by Galadhrim »

What happens when you comment the part of global in this line (line 64 in htlive.c:

Code: Select all

static Function *global = NULL, *channels_funcs = NULL,*server_funcs = NULL;
change to

Code: Select all

static Function *channels_funcs = NULL,*server_funcs = NULL;
I think demond is right as you have no real error in your code. It would not be advisable to change the name of eggdrop's global variable, but then again it is not advisable to change the curl's global variable either :S
Be sure to replace the name in all the files of either program if you do.
m
makam
Voice
Posts: 15
Joined: Thu Jul 08, 2004 1:16 am
Location: Montevideo, Uruguay
Contact:

Post by makam »

Galadhrim wrote:What happens when you comment the part of global in this line (line 64 in htlive.c:

Code: Select all

static Function *global = NULL, *channels_funcs = NULL,*server_funcs = NULL;
change to

Code: Select all

static Function *channels_funcs = NULL,*server_funcs = NULL;

But it dont resolve anything.
I use nmalloc, where is defined in the global variable.
Also i need register the module, in the _start function.

Code: Select all

char *htlive_start(Function *global_funcs) {
  p_tcl_bind_list H_temp;
  global = global_funcs;
  module_register(MODULE_NAME, htlive_table, HTLIVE_MAJORV, HTLIVE_MINORV);
:evil: :evil: ............. :cry:
--
Web: http://www.makam.org/
Chans: #Uruguay,#Hattricklatino@UnderNet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

there is no global identifier in curl.h, you somehow messed up that in your code
m
makam
Voice
Posts: 15
Joined: Thu Jul 08, 2004 1:16 am
Location: Montevideo, Uruguay
Contact:

Fixed!

Post by makam »

Well, the solution is very elegant :)

I include the curl's headers file BEFORE src/mod/module.h header :)

So, in the curl.c is "empty"... and the htlive.c:

Code: Select all

.....
#include <string.h> 
#include <curl/curl.h>
#include <curl/easy.h> 

#undef global
#include "src/mod/module.h" 
....
#include "curl.c"
...

I think that the macros defined in module.h doesnt like very much to curl :)


It works!!! :D :D :D
8)
--
Web: http://www.makam.org/
Chans: #Uruguay,#Hattricklatino@UnderNet
Post Reply