Bonjour,
J'ai un projet qui tourne déjà sous linux et je dois le porter sous windows. Pour cela j'ai installé Visual Studio 8 et je compile avec cl (le comilateur de windows). Or lors de la phase de compilation j' obtiens le message d'erreur suivant (je précise que sous linux je n' ai ni warnings ni erreurs à la compilation):
J'ai eu beau chercher toute l'après-midi je n'ai pas réussi à résoudre ce problème je m'en remet donc à vos lumières (parce que je suis à deux doigts d'exploser mon pc).
Code : Sélectionner tout - Visualiser dans une fenêtre à part rtexception.cpp(31) : error C2679: '<<' binaire: aucun opérateur trouvé qui accepte un opérande de partie droite de type 'const std::string' (ou il n'existe pas de conversion acceptable)
Ci-dessous les deux fichiers incriminés:
le header rtexception.hpp:
et le fichier source rtexception.cpp:
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 #ifndef RTEXCEPTION_HPP #define RTEXCEPTION_HPP #include <iostream> namespace Realtime { typedef enum { RT_NO_ERROR, RT_ACQ_FINISHED, RT_BAD_PACKET_ORDER, RT_CONNECTION_CLOSED, RT_CONNECTION_REFUSED, RT_FINISHED, RT_HOST_NOT_FOUND, RT_INVALID_EVENT, RT_INVALID_MARKER, RT_INVALID_TIME_VALUE, RT_NETWORK_ERROR, RT_NO_MEM, RT_NULL_POINTER, RT_THREAD_NOT_RUNNING, RT_THREAD_RUNNING, RT_THREAD_TERMINATED, RT_TIMEOUT_EXPIRED, RT_UNKNOWN_EVENT, RT_UNKNOWN_ERROR } RTError; class RTException { friend std::ostream &operator<<(std::ostream &os, const RTException &ex); private: RTError error; std::string thrower; public: RTException(RTError error=RT_NO_ERROR); ~RTException(); RTError getError() const; std::string getThrower() const; static void printError(RTError error); void setError(RTError error); void setThrower(const std::string &thrower); }; } #endif /* RTEXCEPTION_HPP */
D'avance merci
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 #include "rtexception.hpp" using namespace Realtime; using namespace std; static const char *const errorAsString[]= { "Success", "Acquisition is finished", "Packet have been received in bad order", "The remote host closed the connection", "The connection was refused by the peer (or timed out)", "Finished signal has been sent", "The host address was not found", "Invalid event", "Invalid marker", "Invalid time value", "An error occurred with the network", "Cannot allocate memory", "Null pointer passed as argument", "Thread is not running, use CollectData::start() to start it", "Thread is running", "A thread has terminated abnormally", "Timeout expired", "Unknown event", "Unknown error...Sorry:(" }; ostream &Realtime::operator<<(std::ostream &os, const RTException &ex) { os << ex.thrower << ": " << errorAsString[ex.error]; return os; } RTException::RTException(RTError error) { this->error=error; return; } RTException::~RTException() { } RTError RTException::getError() const { return error; } std::string RTException::getThrower() const { return thrower; } void RTException::printError(RTError error) { cerr << errorAsString[error] << endl; return; } void RTException::setError(RTError error) { this->error=error; return; } void RTException::setThrower(const std::string &thrower) { this->thrower=thrower; return; }
Partager