Programación de ns: problemas de mezclar C++ con Tcl sin dosis elevadas de cafeína

Technorati Tags: , , ,

Las cosas que pasan cuando se programan módulos de ns, que requiere mezclar los lenguajes C++ y Tcl, que tienen una sintaxis bastante diferente.

ns@autoslocos:~/ns-allinone-2.29-dev/ns-2.29$ make
g++ -c -Wall -DTCP_DELAY_BIND_ALL -DNO_TK -DTCLCL_CLASSINSTVAR -DNDEBUG -DLINUX_TCP_HEADER -DUSE_SHM -DHAVE_LIBTCLCL -DHAVE_TCLCL_H -DHAVE_LIBOTCL1_11 -DHAVE_OTCL_H -DHAVE_LIBTK8_4 -DHAVE_TK_H -DHAVE_LIBTCL8_4 -DHAVE_TCL_H -DHAVE_CONFIG_H -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=std -DUSE_SINGLE_ADDRESS_SPACE -Drng_test -I. -I/home/ns/ns-allinone-2.29/tclcl-1.17 -I/home/ns/ns-allinone-2.29/otcl-1.11 -I/home/ns/ns-allinone-2.29/include -I/home/ns/ns-allinone-2.29/include -I/usr/include/pcap -I./tcp -I./sctp -I./common -I./link -I./queue -I./adc -I./apps -I./mac -I./mobile -I./trace -I./routing -I./tools -I./classifier -I./mcast -I./diffusion3/lib/main -I./diffusion3/lib -I./diffusion3/lib/nr -I./diffusion3/ns -I./diffusion3/filter_core -I./asim/ -I./qs -I./diffserv -I./satellite -I./wpan -I./amor -I./OBS -I./monitor -o amor/rtProtoamor.o amor/rtProtoamor.cc
amor/rtProtoamor.cc: In member function ‘virtual void VarianceTimer::expire(Event*)’:
amor/rtProtoamor.cc:32: error: expected `(‘ before ‘{’ token
amor/rtProtoamor.cc:33: error: expected `;’ before string constant
amor/rtProtoamor.cc:33: aviso: statement es una referencia, no una llamada, a la función ‘puts’
amor/rtProtoamor.cc:33: aviso: statement no tiene efecto
amor/rtProtoamor.cc:34: error: expected primary-expression before ‘else’
amor/rtProtoamor.cc:34: error: expected `;’ before ‘else’
make: *** [amor/rtProtoamor.o] Error 1

Código causante del error:

void AMORTimer::expire (Event *e) {
Tcl & tcl = Tcl::instance();
tcl.evalf(«%s calcula-costes», agente_->name());
const char * resultString = tcl.result();
int cambios = atoi(resultString);

if {$cambios == 0} {
puts «No hay cambios»
} else {
puts «Hay cambios»
}
resched(delay);
}

Cualquier parecido con la realidad es pura coincidencia.

Share

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

No comments yet.

Sorry, the comment form is closed at this time.