I have a C++ program that HAS to use a C based API for a specific task. If I include only in to a single cpp in my program I have no problems at all. However if I include in to a header file (where I need to use some types) I get redefinition errors by the linker.
This is due to a number of typedefs made in the external libraries (C header with compiled dll) header. I am looking for any possible solutions to this problem.
When I search all I can seem to find is header guard stuff (and #pragma once) but these aren't the solution to the problem as what I am finding is multiple definitions in separate compilation units that are then conflicting whilst linking.
I was thinking about extern but found that I am unable to use any types defined in the header as members in a C++ class, which is mostly what I am trying to do.
Output for building on Warning Level 4
Warning 1   warning C4273: 'getwchar' : inconsistent dll linkage    c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h  615 1   project-test
Warning 2   warning C4273: 'putwchar' : inconsistent dll linkage    c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h  617 1   project-test
Warning 3   warning C4273: 'getwchar' : inconsistent dll linkage    c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h  615 1   project-test
Warning 4   warning C4273: 'putwchar' : inconsistent dll linkage    c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h  617 1   project-test
Warning 5   warning C4100: 'data' : unreferenced formal parameter   c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  8   1   project-test
Warning 6   warning C4100: 'event' : unreferenced formal parameter  c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  8   1   project-test
Warning 7   warning C4100: 'widget' : unreferenced formal parameter c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  8   1   project-test
Warning 8   warning C4100: 'data' : unreferenced formal parameter   c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  15  1   project-test
Warning 9   warning C4100: 'event' : unreferenced formal parameter  c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  15  1   project-test
Warning 10  warning C4100: 'widget' : unreferenced formal parameter c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  15  1   project-test
Warning 11  warning C4505: 'g_bit_nth_lsf' : unreferenced local function has been removed   c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gutils.h   267 1   project-test
Warning 12  warning C4505: 'g_bit_nth_msf' : unreferenced local function has been removed   c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gutils.h   269 1   project-test
Warning 13  warning C4505: 'g_bit_storage' : unreferenced local function has been removed   c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gutils.h   271 1   project-test
Warning 14  warning C4505: 'g_string_append_c_inline' : unreferenced local function has been removed    c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gstring.h  130 1   project-test
Warning 15  warning C4505: 'g_trash_stack_push' : unreferenced local function has been removed  c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gtrashstack.h  44  1   project-test
Warning 16  warning C4505: 'g_trash_stack_pop' : unreferenced local function has been removed   c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gtrashstack.h  46  1   project-test
Warning 17  warning C4505: 'g_trash_stack_peek' : unreferenced local function has been removed  c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gtrashstack.h  47  1   project-test
Warning 18  warning C4505: 'g_trash_stack_height' : unreferenced local function has been removed    c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gtrashstack.h  48  1   project-test
Error   19  error LNK2005: "long __cdecl abs(long)" (?abs@@YAJJ@Z) already defined in FitsFile.obj  C:\Users\Ian\SkyDrive\Documents\Uni\FINPRO\projects\project-test\project-test\main.obj  project-test
Error   20  error LNK2005: "__int64 __cdecl abs(__int64)" (?abs@@YA_J_J@Z) already defined in FitsFile.obj  C:\Users\Ian\SkyDrive\Documents\Uni\FINPRO\projects\project-test\project-test\main.obj  project-test
Error   21  error LNK2005: "struct _ldiv_t __cdecl div(long,long)" (?div@@YA?AU_ldiv_t@@JJ@Z) already defined in FitsFile.obj   C:\Users\Ian\SkyDrive\Documents\Uni\FINPRO\projects\project-test\project-test\main.obj  project-test
Error   22  error LNK2005: "struct _lldiv_t __cdecl div(__int64,__int64)" (?div@@YA?AU_lldiv_t@@_J0@Z) already defined in FitsFile.obj  C:\Users\Ian\SkyDrive\Documents\Uni\FINPRO\projects\project-test\project-test\main.obj  project-test
Error   23  error LNK2005: _getwchar already defined in FitsFile.obj    C:\Users\Ian\SkyDrive\Documents\Uni\FINPRO\projects\project-test\project-test\main.obj  project-test
Error   24  error LNK2005: _putwchar already defined in FitsFile.obj    C:\Users\Ian\SkyDrive\Documents\Uni\FINPRO\projects\project-test\project-test\main.obj  project-test
Error   25  error LNK1169: one or more multiply defined symbols found   C:\Users\Ian\SkyDrive\Documents\Uni\FINPRO\projects\project-test\Debug\project-test.exe project-test

Output for building on Warning Level 4 (when only including for one place)
Warning 1   warning C4273: 'getwchar' : inconsistent dll linkage    c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h  615 1   project-test
Warning 2   warning C4273: 'putwchar' : inconsistent dll linkage    c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h  617 1   project-test
Warning 3   warning C4100: 'data' : unreferenced formal parameter   c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  8   1   project-test
Warning 4   warning C4100: 'event' : unreferenced formal parameter  c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  8   1   project-test
Warning 5   warning C4100: 'widget' : unreferenced formal parameter c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  8   1   project-test
Warning 6   warning C4100: 'data' : unreferenced formal parameter   c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  15  1   project-test
Warning 7   warning C4100: 'event' : unreferenced formal parameter  c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  15  1   project-test
Warning 8   warning C4100: 'widget' : unreferenced formal parameter c:\users\ian\skydrive\documents\uni\finpro\projects\project-test\project-test\main.cpp  15  1   project-test
Warning 9   warning C4505: 'g_bit_nth_lsf' : unreferenced local function has been removed   c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gutils.h   267 1   project-test
Warning 10  warning C4505: 'g_bit_nth_msf' : unreferenced local function has been removed   c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gutils.h   269 1   project-test
Warning 11  warning C4505: 'g_bit_storage' : unreferenced local function has been removed   c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gutils.h   271 1   project-test
Warning 12  warning C4505: 'g_string_append_c_inline' : unreferenced local function has been removed    c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gstring.h  130 1   project-test
Warning 13  warning C4505: 'g_trash_stack_push' : unreferenced local function has been removed  c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gtrashstack.h  44  1   project-test
Warning 14  warning C4505: 'g_trash_stack_pop' : unreferenced local function has been removed   c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gtrashstack.h  46  1   project-test
Warning 15  warning C4505: 'g_trash_stack_peek' : unreferenced local function has been removed  c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gtrashstack.h  47  1   project-test
Warning 16  warning C4505: 'g_trash_stack_height' : unreferenced local function has been removed    c:\users\ian\skydrive\documents\uni\finpro\gtk\include\glib-2.0\glib\gtrashstack.h  48  1   project-test
