extern

How do I stop name-mangling of my DLL's exported function?

I'm trying to create a DLL that exports a function called "GetName". I'd like other code to be able to call this function without having to know the mangled function name. My header file looks like this: #ifdef __cplusplus #define EXPORT extern "C" __declspec (dllexport) #else #define EXPORT __declspec (dllexport) #endif EXPORT TCHA...

How to set up a C++ function so that it can be used by p/invoke?

Hopefully this is a brainlessly easy question, but it shows my lack of expertise with C++. I'm a C# programmer, and I've done extensive work with P/Invoke in the past with other people's C++/C dlls. However, this time I've decided to write a wrapper C++ dll (unmanaged) myself, and am then calling my wrapper dll from C#. The problem I ...

use of extern methods between dll projects?

I have a debug condition to manage memory where I have extern void* operator new(unsigned int size, const char* file, int line); extern void operator delete(void* address, const char* file, int line); extern void Delete(void* address); #define FUN_NEW new(__FILE__, __LINE__) #define FUN_DELETE delete This exists in...

'operater new': redefinition, different linkage (using _dllspec on redefined new operator)

I am using __declspec(dllimport/export) on a debug version of new as such: #ifdef _DEBUG DECLSPECCORE extern void* operator new(unsigned int size, const char* file, int line); extern void* operator new[](unsigned int size, const char* file, int line); extern void operator delete(void* address, const char* file, int line); extern v...

C#: Implementation of, or alternative to, StrCmpLogicalW in shlwapi.dll

For natural sorting in my application I currently P/Invoke a function called StrCmpLogicalW in shlwapi.dll. I was thinking about trying to run my application under Mono, but then of course I can't have this P/Invoke stuff (as far as I know anyways). Is it possible to see the implementation of that method somewhere, or is there a good, c...

C-DLL from C++ source

I have a C-Wrapper for my C++ Framework. Since this should run on mac and windows I am using scons: env = Environment() env.Append(CPPPATH = ['./']) env.Append(LIBS = 'kernel32.lib') env.Append(LIBPATH = 'C:/Program Files/Microsoft SDKs/Windows/v6.0A/Lib') env.SharedLibrary(target='warpLib', source='warplib.cpp') Simple Versions of w...

Using extern in C doesn't work as expected

Hi, I have created two files: tunables.h #ifndef TUNABLES_H #define TUNABLES_H void tunables_load_conservative(); void tunables_load_aggressive(); extern int timer_x; #endif /*TUNABLES_H */ and tunables.c #include "tunables.h" int timer_x; void tunables_load_conservative(){ timer_x = 3; } void tunables_load_aggressive(){ ...

Question on extern specifier in C

How does the following example usage of extern specifer behave. We have a global variable int x both in files one.c and two.c We want to use these in three.c so have declared this variable in three.c as extern int x; What would happen when we compile and link these files? My answer is: compilation of all these files should succe...

C++ extern class definition

I'm reading some code that goes: extern class MyClass : BaseClass { ... } MyInstance; Does the extern refer to the class declaration or the instance? ...

[C++] Mixing extern and const

Can I mix extern and const, as extern const? If yes, does the const qualifier impose it's reign only within the scope it's declared in or should it exactly match the declaration of the translational unit it's declared in? I.e. can I declare say extern const int i; even when the actual i is not a const and vice versa? ...

How to optimize an external reference to an interface in C++?

Using VC8, I create two modules similar to the following: Header class IFoo { virtual void Bar() = 0; }; Module A extern IFoo& Foo; void DoStuff() { Foo.Bar(); } Module B IFoo& Foo = ConcreteFoo(); VC8 handles this by essentially treating 'Foo' as a pointer to an IFoo. Wherever it sees Foo.Bar() (even in module B), it...

How can I define two global `const` variables to the same value in a C module?

I’m using a pair of global variables in one of my .c files, matched to a single extern declaration each in two different .h files (well, one .h file, preprocessed two ways). One is for public consumption, and one is for private use. Both are const variables. I only want to initialize one of the variables in my .c file, and then assign t...

Ascess the instance variable globally in objective c

I am new to iphone development.I want to access a variable declared in one view in another view.How can i achieve it.Whether it is possible by using extern variable, if so how to declare and implement it.Can i achieve it by using delegates?then so how to implement it.Please guide me.I am browsing google to get and idea to achieve it, i ...

How to properly use extern in a namespace?

I'm working on getting rLog to build as a DLL under windows, and I was getting undefined symbol errors relating to some global symbols in the rlog namespace. Specifically these in RLogChannel.cpp: namespace rlog { ... RLogChannel *_RLDebugChannel = GetGlobalChannel( "debug", Log_Debug ); RLogChannel *_RLInfoChannel = GetGlob...

Using extern to include files in C or C++

How this works in C or C++? extern "C" { #include <unistd.h> #include <fd_config.h> #include <ut_trace.h> #include <sys/stat.h> #include <sys/types.h> } ...

Doubt related to extern keyword usage.

AFAIK, extern keyword should be used for declaration and no value can be associated with the variable being declared with extern keyword. But supposing I write a statement like extern int i = 10; Should the compiler flag an error for the same? I have seen some compilers being tolerant and ignoring this? Why is this so? What does the '...

Why does this separate definition cause an error?

Solution: This is an interesting problem, because sometimes we have no choice but to declare an explicitly qualified name. std::string convert(); namespace tools { class Numeric { // ... // parsed as: "friend std::string::convert ();" // (actual name is missing!). friend std::string ::convert(); }; } In that c...

How does an "extern C" declaration work?

I'm taking a programming languages course and we're talking about the "extern C" declaration. How does this declaration work at a deeper level other than "it interfaces C and C++"? How does this affect the bindings that take place in the program as well? ...

extern "C" has no effect in msvc++ 9.0

I manage project for JNI for both compilers: MSVC++ 8.0 and 9.0, my cpp file contains following implementation: extern "C" { JNIEXPORT jlong JNICALL Java_context_ServiceProviderContext_StartServiceProvider (JNIEnv * env, jclass, jstring jspath){ ..... } With help of depends.exe utility I can see that MSVC 8.0 successfu...

Clock problem with FTDIchip FT2232 MPSSE mode

Hello, I'm trying to write/read to an extern device connected to a FTDIchip FT2232 MPSSE mode using SPI. I'm using the SPI function given by FTDI for Labview. I'm doing this: Open_Device - Init_Device - Write/Read - Close_Device The problem is that I don't have a clock signal on the scope when I try to read/write. Do you have a solut...