RE: help me

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> hi list
> I need help
>  I make Dynamic-link library in c
> I want link it from a C++
> 
> I Create .h file like this
> #ifdef __cplusplus
> extern "C" {  // only need to export C interface if
>               // used by C++ source code #endif __declspec( dllimport )
>     static void flood_loop(MAP *map, int x, int y,
>       unsigned int dst_c, unsigned  int src_c); #ifdef __cplusplus }
> #endif


I made the mistake earlier of *not* replying to all on this one.  So, here's my question to the OP with his response:

AF> How do you know it doesn't work?  What are the error messages?

ALI> 5: error: expected `,' or `...' before '(' token
ALI> 		5: error: expected `)' before ';' token
ALI> 5: error: storage class specifiers invalid in parameter declarations
ALI> 5: error: storage class specified for parameter `flood_loop'
ALI> 5: error: `flood_loop' has incomplete type
ALI> 5: error: invalid use of `void'

I don't know if the formatting is messed up because of copy/paste issues but the first thing I'd try is making sure that the #endif directives are on lines by themselves.

#ifdef __cplusplus
extern "C" {
#endif

// stuff

#ifdef __cplusplus
}
#endif

Other than that, it's not clear if you're building for Windows or not.  It looks like, if GCC wasn't compiled for Windows support, it may not know how to handle the __declspec() syntax.  Look through the GCC docs for more info.

Andy





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux