sommer / veins

Veins - The open source vehicular network simulation framework.
http://veins.car2x.org
GNU General Public License v2.0
293 stars 227 forks source link

OMNET++5.1.1 build with error #31

Closed ChenKangQiang closed 7 years ago

ChenKangQiang commented 7 years ago
Welcome to OMNeT++ 5.1.1!

/c/VANET/omnetpp-5.1.1$ cd ..

/c/VANET$ cd veins-4.5/

/c/VANET/veins-4.5$ ./configure
Creating Makefile in /c/VANET/veins-4.5/src...
Configure done. You can now run "make".

/c/VANET/veins-4.5$ make
Creating script "./run"
Creating script "./debug"
Creating script "./memcheck"
make[1]: entering directory “/c/VANET/veins-4.5/src”
MSGC: veins/base/messages/AirFrame.msg
MSGC: veins/base/messages/BorderMsg.msg
MSGC: veins/base/messages/ChannelSenseRequest.msg
MSGC: veins/base/messages/MacPkt.msg
MSGC: veins/modules/messages/AirFrame11p.msg
MSGC: veins/modules/messages/BasicSafetyMessage.msg
MSGC: veins/modules/messages/Mac80211Pkt.msg
MSGC: veins/modules/messages/PhyControlMessage.msg
MSGC: veins/modules/messages/WaveServiceAdvertisement.msg
MSGC: veins/modules/messages/WaveShortMessage.msg
veins/base/connectionManager/BaseConnectionManager.cc
veins/base/connectionManager/ChannelAccess.cc
veins/base/connectionManager/ConnectionManager.cc
veins/base/connectionManager/NicEntryDebug.cc
veins/base/connectionManager/NicEntryDirect.cc
veins/base/modules/BaseApplLayer.cc
veins/base/modules/BaseBattery.cc
veins/base/modules/BaseLayer.cc
veins/base/modules/BaseMacLayer.cc
veins/base/modules/BaseMacLayer.cc: In member function 'virtual void BaseMacLayer::initialize(int)':
veins/base/modules/BaseMacLayer.cc:74:67: error: cast from 'const char*' to 'LAddress::L2Type {aka long int}' loses precision [-fpermissive]
                 myMacAddr = LAddress::L2Type(addressString.c_str());
                                                                   ^
make[1]: *** [Makefile:174:../out/gcc-debug/src/veins/base/modules/BaseMacLayer.o] error 1
make[1]: leaving directory “/c/VANET/veins-4.5/src”
make: *** [Makefile:12:all] error 2
riebl commented 7 years ago

I cannot reproduce this error using OMNeT++ 5.1.1 on Linux and Veins' master branch. Have you tried the most recent revision or the pristine 4.5 release?

ChenKangQiang commented 7 years ago

I use OMNet++ 5.1.1 in Windows,is it the problem?

riebl commented 7 years ago

I suppose the Windows toolchain is just more strict in this case and hence nobody has noticed this bug on other platforms before. In fact, casting a string (const char*) to long int should always fail. Since Veins sets the "address" parameter to "auto" by default, usually line 72 is executed. As a quick workaround you could simply remove lines 73 and 74.

ChenKangQiang commented 7 years ago

Thank you ! I modify line 75 by myMacAddr = LAddress::L2Type(atol(addressString.c_str())), it seems OK!

riebl commented 7 years ago

@sommer please merge bug fix

sommer commented 7 years ago

Presumed fixed in Veins 4.6