[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] Problem with Compiling NS
pls try the attached file, I used to ask the same question. you can search
the archive to follow the details.
good lucks,
yan
On Mon, 10 Jul 2000, Jalil Halim wrote:
> Hi Evrybody,
>
> m trying to compile NS using ns-allinone-2.1b6 and
> i have this problem :
> c++ -c -O2 -I.
> -I/infres/goriot/car/halim/ns/ns-allinone-2.1b6/tclcl-1.0b9
> -I/infres/goriot/car/halim/ns/ns-allinone-2.1b6/otcl-1.0a5
> -I/infres/goriot/car/halim/ns/ns-allinone-2.1b6/tk8.0.4/generic
> -I/infres/goriot/car/halim/ns/ns-allinone-2.1b6/tcl8.0.4/generic -o
> my-endian.o my-endian.cc
> my-endian.cc: In function `void ToOtherEndian(TEntry *)':
> my-endian.cc:42: conversion from `short unsigned int' to `enum method_t'
>
> my-endian.cc:45: conversion from `u_4bytes' to `enum method_t'
> my-endian.cc:48: conversion from `short unsigned int' to `enum
> protocol_t'
> my-endian.cc:51: conversion from `u_4bytes' to `enum protocol_t'
> *** Error code 1
> make: Fatal error: Command failed for target `my-endian.o'
>
> Could some one helps me .. :(
>
> Thnx
>
>
>
#include "my-endian.h"
/* rotates 2 bytes */
unsigned short swap2(u_2bytes In) {
u_2bytes Out;
((char*)&(Out))[0] = ((char*)&(In))[1];
((char*)&(Out))[1] = ((char*)&(In))[0];
return Out;
}
/* rotates 4 bytes */
u_4bytes rotate4(u_4bytes In) {
u_4bytes Out;
((u_2bytes*)&Out)[0] = swap2(((u_2bytes*)&In)[1]);
((u_2bytes*)&Out)[1] = swap2(((u_2bytes*)&In)[0]);
return Out;
}
/* detects endian-ness
* Note: will not work if sizeof(unsigned long)==1
*/
int IsLittleEndian(void) {
static const unsigned long long_number = 1;
return *(const unsigned char *)&long_number;
}
/* changes endian-ness */
void ToOtherEndian(TEntry *e) {
/* unroll this loop if you want to enumerate u_4bytes members of TEntry_v2 */
u_4bytes *p;
for (p = &(e -> head.event_duration); p <= &(e -> url); p++)
*p = rotate4(*p);
e -> tail.status = swap2(e -> tail.status);
if (sizeof(method_t) == 2)
e -> tail.method = (method_t) swap2(e -> tail.method);
else
if (sizeof(method_t) == 4)
e -> tail.method = (method_t) rotate4(e -> tail.method);
if (sizeof(protocol_t) == 2)
e -> tail.protocol = (protocol_t) swap2(e -> tail.protocol);
else
if (sizeof(protocol_t) == 4)
e -> tail.protocol = (protocol_t) rotate4(e -> tail.protocol);
}