Old 3rd August 2008, 16:37   #1
LordNeo Angelus
Junior Member
 
Join Date: Aug 2008
Posts: 3
Problems using C++

Greetings Everyone,

I have some problems creating a general plugin DLL. I use Visual Studio 2005 Professional edition and I have been able to compile and edit an 'Empty project' found here on the forums.

So when Winamp recognised my adaptation of the 'Empty Project' I decided to begin with a fresh project. I chose Win32->DLL(with Empty Project selected)->Finish and made the code almost identical to the code of the 'Empty Project'. It would compile, but sadly enough Winamp wouldn't recognize the DLL.(wouldn't show up as plugin) I used the following code:

File: gen_NA.h
code:
#include <GEN.h>


File: gen_NA.cpp
code:
#include <windows.h>
#include "gen_NA.h"

int init(void);
void config(void);
void quit(void);

winampGeneralPurposePlugin plugin = {
GPPHDR_VER,
"Neo Angelus v0.1 (gen_NA.dll)", // Plug-in description
init,
config,
quit,
};

int init() {
return 0;
}

void config() {
MessageBox(plugin.hwndParent,L"Config",L"",MB_OK);
}

void quit() {
}

__declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() {
return &plugin;
}



I couldn't figure out what was wrong, until I renamed gen_NA.cpp to gen_NA.c. I compiled and Winamp recognized the plugin.

This gave only one problem: I couldn't use my struct's any more.

Thus I wanted to ask, can I use *.cpp in my plugin? And if I can how can I fix the problem of Winamp not recognizing my DLL if I compile it with *.cpp? ...and|or...could anyone be so kind to give me a Visual Studio 2005 Project of a stripped down General plugin using *.cpp?(as all examples seem to be of older versions of VC)

I really hope someone can help me...and I am really sorry if this kind of question has been asked and ansered before, but I searched the forums and couldn't find an answer to my problem.
LordNeo Angelus is offline   Reply With Quote
Old 3rd August 2008, 18:57   #2
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
If you are using C++, then:
Quote:
export "C" __declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() {
return &plugin;
}
typical mistake from C -> C++


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 3rd August 2008, 19:10   #3
LordNeo Angelus
Junior Member
 
Join Date: Aug 2008
Posts: 3
Thank you...but now it still doesn't work yet

I replaced
code:
__declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() {
return &plugin;
}



with
code:
export "C" __declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() {
return &plugin;
}



But then my DLL won't compile and gives the following errors and warnings:

code:
1>------ Build started: Project: gen_NA, Configuration: Release Win32 ------
1>Compiling...
1>gen_NA.cpp
1>.\gen_NA.cpp(91) : warning C4237: 'export' keyword is not yet supported, but reserved for future use
1>.\gen_NA.cpp(91) : error C2143: syntax error : missing ';' before 'string'
1>.\gen_NA.cpp(91) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\gen_NA.cpp(91) : error C2143: syntax error : missing ';' before '{'
1>.\gen_NA.cpp(91) : error C2447: '{' : missing function header (old-style formal list?)
1>gen_NA - 4 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



(line numbers don't really match my previous example code any more...but line 91 is the line which says export "C"...)
LordNeo Angelus is offline   Reply With Quote
Old 3rd August 2008, 23:34   #4
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Dude! Sorry for you from having a terrible compiler

From Microsoft I use Visual Studio 6.0 SP6, old..yeah..but at least the dumb compiler works..also minGW is the coolest.


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 3rd August 2008, 23:50   #5
LordNeo Angelus
Junior Member
 
Join Date: Aug 2008
Posts: 3
Strange that the newer version doesn't support syntax the older one did(...or not).

Guess I have to search the internet for a solution...

K...I found it(more easily than expected...guess sleep makes me more vigilant)

In Visual Studio 2005 it isn't
code:
export "C" __declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() {
return &plugin;
}



but
code:
extern "C" __declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() {
return &plugin;
}



I tried it and the problem was solved...thanks again
LordNeo Angelus is offline   Reply With Quote
Old 4th August 2008, 00:12   #6
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
oops, that was the correct one...
now I feel n00b


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 4th August 2008, 11:16   #7
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
joel, msvc6 does not come with a standard compliant C++ compiler. none of the service packs fixes the issues

so no, the compiler doesnt really work...

btw "export" is for exporting templates and is currently only supported by one compiler: comeau

If you can't say something nice, say something surrealistic.

Last edited by TomyLobo; 4th August 2008 at 13:08.
TomyLobo is offline   Reply With Quote
Old 4th August 2008, 14:31   #8
DrO
 
Join Date: Sep 2003
Posts: 27,873
should always be extern "C" as all of the examples have used.

-daz
DrO is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump