Bug 1680

Summary: There is a problem in the tutorial code
Product: ns-3 Reporter: tarunumehta
Component: examplesAssignee: ns-bugs <ns-bugs>
Status: RESOLVED INVALID    
Severity: normal CC: tomh
Priority: P5    
Version: ns-3.15   
Hardware: PC   
OS: Linux   
Attachments: modified file(Third.cc).

Description tarunumehta 2013-05-12 02:40:55 UTC
Created attachment 1596 [details]
modified file(Third.cc).

I m trying to run the example file(Third.cc) after the modification (adding lines of code as per the tutorial.....http://www.nsnam.org/docs/release/3.13/tutorial/html/building-topologies.html#building-a-wireless-network-topology) and I m getting several errors after I run the simulation command.

Waf: Entering directory `/home/infinite/Documents/tar/ns-allinone-3.15/ns-3.15/build'
[  5/376] cxx: third.cc -> ../../build/examples/tutorial/third.cc.4.o
../examples/tutorial/third.cc:39:36: error: ‘Ptr’ has not been declared
../examples/tutorial/third.cc:39:39: error: expected ‘,’ or ‘...’ before ‘<’ token
../examples/tutorial/third.cc: In function ‘void CourseChange(std::string, int)’:
../examples/tutorial/third.cc:41:3: error: ‘Vector’ was not declared in this scope
../examples/tutorial/third.cc:41:3: note: suggested alternative:
./ns3/vector.h:118:18: note:   ‘ns3::Vector’
../examples/tutorial/third.cc:41:10: error: expected ‘;’ before ‘position’
../examples/tutorial/third.cc:42:3: error: ‘position’ was not declared in this scope
Waf: Leaving directory `/home/infinite/Documents/tar/ns-allinone-3.15/ns-3.15/build'
Build failed
 -> task in 'third' failed (exit status 1): 
	{task 170951148: cxx third.cc -> third.cc.4.o}
['/usr/bin/g++', '-O0', '-ggdb', '-g3', '-Wall', '-Werror', '-Wno-error=deprecated-declarations', '-fstrict-aliasing', '-Wstrict-aliasing', '-pthread', '-pthread', '-Ibuild', '-I.', '-I.', '-I/home/infinite/Documents/tar/ns-allinone-3.15', '-I/usr/include/gtk-2.0', '-I/usr/lib/i386-linux-gnu/gtk-2.0/include', '-I/usr/include/atk-1.0', '-I/usr/include/cairo', '-I/usr/include/gdk-pixbuf-2.0', '-I/usr/include/pango-1.0', '-I/usr/include/gio-unix-2.0', '-I/usr/include/glib-2.0', '-I/usr/lib/i386-linux-gnu/glib-2.0/include', '-I/usr/include/pixman-1', '-I/usr/include/freetype2', '-I/usr/include/libpng12', '-I/usr/include/libxml2', '-DNS3_ASSERT_ENABLE', '-DNS3_LOG_ENABLE', '-DHAVE_PACKET_H=1', '-DHAVE_DL=1', '-DSQLITE3=1', '-DHAVE_IF_TUN_H=1', '-DENABLE_GSL', '../examples/tutorial/third.cc', '-c', '-o', 'examples/tutorial/third.cc.4.

Attached is my modified file(Third.cc). 

Can you please check and tell whats wrong with it.
thanks
Comment 1 Tom Henderson 2013-05-12 14:46:09 UTC
the CourseChange function must be added after the

using namespace ns3;

statement.

I added this small clarification to the tutorial to try to avoid this in the future:

-Just before the main program of the ``scratch/mythird.cc`` script, add the 
+Just before the main program of the ``scratch/mythird.cc`` script (i.e.,
+just after the ``NS_LOG_COMPONENT_DEFINE`` statement), add the