Bonjour, je ne sais pas si je suis dans le bon topic mais puisque je travaille en C, peut être que oui.
Voilà ma question concerne une commande pour le préprocesseur qui me retourne les librairies pour windows si je suis sur windows ou idem pour Linux.
Je ne vois pas d'où viens mon erreur ...
Voici le message d'erreur quand je compile main sur Linux (main a comme en-tête #include "LOpenGL.h") :
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 #ifndef LOPENGL_H #define LOPENGL_H #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #ifdef defined(__gnu__linux__) || defined(__linux__) printf( "You are on a Linux platform\n" ); #include <GL/glut.h> // GLUT, includes glu.h and gl.h #include <stdio.h> #elif WIN32 /* Only defined on Windows platforms */ printf( "You are on a Windows platform\n" ); #include <windows.h> // For MS Windows #include <GL/freeglut.h> #include <GL/GL.h> #else printf( "You are on an other platform\n" ); #error "OS not supported!" #endif
Par contre, ce programme fonctionne très bien :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 LOpenGL.h:8:15: warning: extra tokens at end of #ifdef directive #ifdef defined(__gnu__linux__) || defined(__linux__) ^ LOpenGL.h:20:10: error: expected declaration specifiers or ‘...’ before string constant printf( "You are on an other platform\n" ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LOpenGL.h:21:2: error: #error "OS not supported!" #error "OS not supported!" ^~~~~ In file included from main.c:1:0: LOpenGL.h:1:0: error: unterminated #ifndef #ifndef LOPENGL_H
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 #include <stdio.h> int main() { #ifdef WIN32 /* Only defined on Windows platforms */ printf( "You are on a Windows platform\n" ); #elif defined(__gnu__linux__) || defined(__linux__) printf( "You are on a Linux platform\n" ); #else /* Probably a Unix/Linux platform */ printf( "You are on an other platform\n" ); #endif return 0; }
Partager