Home/Support/Support Forum/_tcp_notify() in tcp.lib doesnt like icmp_ip_t in icmp.lib
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

_tcp_notify() in tcp.lib doesnt like icmp_ip_t in icmp.lib

0 votes
I've taken over quite a code base, and in teasing it apart as part of a re-factoring, I've managed to generate an error I don't understand. What's worse, I haven't even touched the Rabbit libs (and apparently no one in my company has either, at least the ones affected here, tcp.lib and icmp.lib). Why in the world they should start failing is beyond me.

I've found a work-around by declaring a local version of struct typedef icmp_ip_t, but I would like to understand what the problem is. Please find the code below from tcp.lib, followed by the compiler errors when trying to use the typedef icmp_ip_t in icmp.lib.

The line 1813 refers to the function prototype, the actual function declaration doesn't seem to affect the results.

Thanks in advance.


/*** BeginHeader _tcp_notify */

// typedef struct icmp_ip { // Here's the one defined in icmp.lib.
// byte type; // Used as a template to create icmp_ip_t_local below.
// byte code;
// word checksum;
// longword ipaddr;
// in_Header ip;
// } icmp_ip_t;

typedef struct { // Here's the local copy, without struct name.
byte type;
byte code;
word checksum;
longword ipaddr;
in_Header ip;
} icmp_ip_t_local;

typedef struct icmp_ip_local { // Here's the local copy, with a struct name.
byte type;
byte code;
word checksum;
longword ipaddr;
in_Header ip;
} icmp_ip_t_local2;

//void _tcp_notify(icmp_ip_t * icmp, byte msg, ll_prefix __far * LL); // Doesn't work.
//void _tcp_notify(icmp_ip_t_local * icmp, byte msg, ll_prefix __far * LL); // Works.
void _tcp_notify(icmp_ip_t_local2 * icmp, byte msg, ll_prefix __far * LL); // Works.
/*** EndHeader */

//_tcp_nodebug void _tcp_notify(icmp_ip_t * icmp, byte msg, ll_prefix __far * LL) // Doesn't work.
//_tcp_nodebug void _tcp_notify(icmp_ip_t_local * icmp, byte msg, ll_prefix __far * LL) // Works.
_tcp_nodebug void _tcp_notify(icmp_ip_t_local2 * icmp, byte msg, ll_prefix __far * LL) // Works.
{
// This is upcalled from ICMP when we get a message relating to the TCP protocol.
auto in_Header * ip;
(etc...)

line 1813 : ERROR TCP.LIB : ',' is missing/expected.
line 1813 : ERROR TCP.LIB : Syntax error - or garbage at end of program.
line 1813 : ERROR TCP.LIB : Need function definition or declaration.
line 1813 : ERROR TCP.LIB : Missing character ';'.
line 1813 : ERROR TCP.LIB : Type does not match declaration on line 172 of file C:\KAIROSRABBIT\DYNAMICC_10.72_LIBS\LIB\RABBIT4000\TCPIP\NET_DEFS.LIB.
line 1813 : ERROR TCP.LIB : Bad declaration: ',' ';' or '=' expected.
line 1813 : ERROR TCP.LIB : Syntax error - or garbage at end of program.
line 1813 : ERROR TCP.LIB : Need function definition or declaration.
line 1813 : ERROR TCP.LIB : Expects ';'.
line 1813 : ERROR TCP.LIB : Old style function declaration missing parameter declaration list.
line 1813 : ERROR TCP.LIB : Missing character ')'.
asked Aug 13, 2015 in Rabbit Software by SR Higgins New to the Community (7 points)

Please log in or register to answer this question.

2 Answers

0 votes
I did come across some issues with DC when using anonymous structs in typedefs before whilst porting some code to DC and found that always having a named struct was the solution so every typedef I make with structs now gets a name!

I've a feeling it is something to do with name space clashes where struct members from different structs clash but I never investigated it further.

Sometimes subtle issues show up in DC when you make slight changes because of the way it only compiles that code it actually needs to in a module based on the function headers so it does not check any of the code in the rest of the module. Most compilers compile a source module and then try to figure out afterwards which bits were not needed (if they support dead code removal). DC tries to figure this out before compiling the code so that it only compiles the bits you use in the libs - this is why libs in DC are supplied in source form instead of binary libs which to provide some chance of code reduction usually consist of a collection of many very small object files.

Regards,
Peter
answered Aug 13, 2015 by petermcs Veteran of the Digi Community (1,130 points)
0 votes
Peter, thanks so much for your thoughts. I don't believe it has anything to do with the struct tag, I have two local structs, with and without the tag, that I can get to work.

It seems to be concerned with tcp.lib not able to use a typedef that's been defined in icmp.lib. If I just copy the typedef into tcp.lib it works fine (after a simple rename). And the code in icmp.lib is happy using the typedef defined there. But using the typedef in a function prototype in tcp.lib, the compiler acts like it's never seen that symbol before.

So it doesn't seem so much like a name space clash to me. And to top it all off, if you use these functions in your code, it may work just fine. I don't know if it's something in my project code that caused this problem. I did copy the entire Rabbit library structure to a new location to make it easier to place under source code control, but all that seems to be working.

I agree with your comment that it may be DC trying to not compile some code that is actually needed. I haven't really any idea how to go about debugging that. I spent a day of brute force just finding the typedef issue. :-P

Stephen
answered Aug 14, 2015 by SR Higgins New to the Community (7 points)
...