Simple question i have this code in an EXE:
so i can use both with the same nameCode:
void foo(int var1); void foo(int var1,int var2);
how can i use this in a DLL my Qt compiler says that the 2 function confilts :confused:
Printable View
Simple question i have this code in an EXE:
so i can use both with the same nameCode:
void foo(int var1); void foo(int var1,int var2);
how can i use this in a DLL my Qt compiler says that the 2 function confilts :confused:
there are plenty of other resources on the net available for building (c++) dlls. This is nothing to do with Qt programming.
Qt is C++ , i didn't ask for trolling i asked for advice...
Qt is not c++. Qt is a library built with c++.
This is a Qt programming forum. You have not asked a Qt programming question.
Maybe here http://www.qtcentre.org/forums/9-General-Programming is what you are looking for.
look go flame somewhere else i have a question i don't need a lecture what Qt u know I'M PROGRAMMING IN Qt do you think i don't know what it is?
you are a programmer in Qt, so rather than trollin' answer or flame another post
Well, you've posted in a wrong forum. That's it. If you're sure that's the correct place to ask then:
Did you fill HEADERS & LIBS variables for your pro-file? What's the complete error message?
Firstly, there is no such beast as a Qt compiler. Your are using either a C++ or C compiler and this question has nothing to do with Qt.
Now, to address the C++ question. By way of example, this code:
Code:
#include <stdio.h> void foo(int a) { printf("A = %d\n", a); } void foo(int a, int b) { printf("A = %d B = %d\n", a, b); } int main(int argc, char **argv) { foo(1); foo(2,3); return 0; }
Is perfectly valid C++, which allows overloaded functions, and compiles just fine with a C++ compiler. Despite deliberately using only C IO functions this code will not compile with a C compiler (GCC in my case), generating:
You are most likely using C++ compiler, but this is still related.Code:
gcc -o test main.c main.c:7:6: error: conflicting types for ‘foo’ main.c:3:6: note: previous definition of ‘foo’ was here main.c: In function ‘main’: main.c:15:5: error: too few arguments to function ‘foo’ main.c:7:6: note: declared here
Even with a C++ compiler, if you have forward declarations in the include file for your library like this:
then you are telling the C++ compiler these are C-style declarations and it will not allow the overloaded names (just like a C compiler):Code:
#ifdef __cplusplus extern "C" { #endif void foo(int var1); void foo(int var1,int var2); #ifdef __cplusplus } #endif
Code:
g++ -o test test.cpp main.cpp In file included from main.cpp:1:0: test.h:6:27: error: declaration of C function ‘void foo(int, int)’ conflicts with test.h:5:6: error: previous declaration ‘void foo(int)’ here main.cpp: In function ‘int main(int, char**)’: main.cpp:6:10: error: too few arguments to function ‘void foo(int, int)’ test.h:6:6: note: declared here
Exactly what you are doing we cannot tell, but this information should give you a clue.