j'ai un probleme de creation de DLL sous dev-cpp (OS XP),
voila mon code :
et voila ce que me it le compilateur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 /* Replace "dll.h" with the name of your header */ #include "dll.h" #include <windows.h> #include <stdio.h> #include <stdlib.h> DLLIMPORT void HelloWorld () { MessageBox (0, "Hello World from DLL!\n", "Hi", MB_ICONINFORMATION); } BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , DWORD reason /* Reason this function is being called. */ , LPVOID reserved /* Not used. */ ) { switch (reason) { case DLL_PROCESS_ATTACH: break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } /* Returns TRUE on success, FALSE on failure */ return TRUE; } DLLIMPORT __declspec (dllexport) char *IP() { WSADATA WSAData; WSAStartup(MAKEWORD(1, 1), &WSAData); char FAR buffer[64] = "", *pt; struct sockaddr_in sin; struct hostent *phe; gethostname(buffer, sizeof(buffer)); phe = gethostbyname(buffer); int I = 0; while(phe->h_addr_list[I + 1] != NULL){ I++; } sin.sin_addr.s_addr = *((unsigned long *) phe->h_addr_list[I]); pt=inet_ntoa(sin.sin_addr); WSACleanup(); return pt; }
D:\Dev-Cpp\dllmain.c [Warning] In function `IP':
34 D:\Dev-Cpp\dllmain.c parse error before `char'
37 D:\Dev-Cpp\dllmain.c `buffer' undeclared (first use in this function)
38 D:\Dev-Cpp\dllmain.c `phe' undeclared (first use in this function)
39 D:\Dev-Cpp\dllmain.c parse error before `int'
40 D:\Dev-Cpp\dllmain.c `I' undeclared (first use in this function)
43 D:\Dev-Cpp\dllmain.c [Warning] built-in function `sin' used without declaration
43 D:\Dev-Cpp\dllmain.c request for member `sin_addr' in something not a structure or union
44 D:\Dev-Cpp\dllmain.c `pt' undeclared (first use in this function)
44 D:\Dev-Cpp\dllmain.c request for member `sin_addr' in something not a structure or union
alors que si je compile ce code dans un programme comme une windows application ou en console application il fonctionne tres bien et me reporte aucune erreur....
est-ce que quelqu'un serait d'ou peut venir ce probleme ?
Partager