Salut tout le monde j'éspère pouvoir trouver de l'aide ;-)
Voici mon problème quoi surtout mon problème de compil donc voici déja mes codes:
un fichier "cmd_line.cpp":
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
| #include <iostream>
#include <string>
#include <vector>
#include "cmd_line.h"
using std::cout;
using std::endl;
using std::string;
using std::vector;
void parseCmdLine(int argc,char const * argv[], bool& reverse, int& step)
{
if(argc == 1)
cout << "pas de commandes !" << endl;
else if(argv[2] == "-h" || argv[2] == "--help"){
cout << "Usage: <nomprog> [option...]" << endl << endl
<< "Options:" << endl
<< " -r, --reverse: views input lines backwards." << endl
<< " --step <step>: defines a strictly positive step between" << endl
<< " displayed lines. Defaults to 1 (one)." << endl
<< " -h, --help: displays this usage info." << endl;
}
else if(reverse == true)
cout << "on inverse" << endl
<< "avec un pas de " << step << " lignes" << endl;
else
cout << "on inverse pas" << endl;
} |
un fichier "cmd_line.h":
1 2 3 4 5 6
| #ifndef _CMD_LINE_H
# define _CMD_LINE_H
void parseCmdLine(int argc, char const * argv[], bool& reverse, int& step);
#endif /* !_CMD_LINE_H */ |
et enfin mon fichier "main.cpp":
1 2 3 4 5 6 7 8 9
| #include "cmd_line.h"
int main(int argc, char const * argv[])
{
bool reverse = false;
int step = 1;
parseCmdLine(argc, argv, reverse, step);
return 0;
} |
et lorsque je compil j'obtiens l'erreur :
/tmp/cccmSCKl.o: In function `main':
main.cpp
.text+0x37): undefined reference to `parseCmdLine(int, char const**, bool&, int&)'
collect2: ld returned 1 exit status
$
et je ne vois pas d'ou cela proviens je ne comprends pas car lorsque dans mon main.cpp je retire la ligne :
parseCmdLine(argc, argv, reverse, step);
cela compil et je ne vois pas ou est mon erreur.
Je vous remercie d'avance pour votre aide ;-)
Partager