Server Help

ASSS Questions - Syntax error in util.c

Anonymous - Wed Feb 27, 2008 11:34 pm
Post subject: Syntax error in util.c
Haven't touched this file at all, simply needed to include it to get autoturret to work, and I get the following errors when compiling autoturret/similar modules:
C:/asss-1.4.4/src/main/util.c:476: error: syntax error before '*' token
C:/asss-1.4.4/src/main/util.c:481: error: syntax error before '*' token

You can all look at the file yourselves, it's undoubtedly the same but here is the code:
Code: Show/Hide

Link * LLGetHead(LinkedList *lst)
{
   return lst->start;
}

int LLIsEmpty(LinkedList *lst)
{
   return lst->start == NULL;
}


Not really sure what to make of that at all. Help?
-JP
tcsoccerman - Thu Feb 28, 2008 4:23 pm
Post subject:
i think it's the double "=". remove one of them in 1rst->start == NULL line
Samapico - Thu Feb 28, 2008 4:32 pm
Post subject:
tcsoccerman wrote:
i think it's the double "=". remove one of them in 1rst->start == NULL line

That would make it return the value of the assigned value. Which would ALWAYS be 0.
So... no.

It says syntax error before... make sure the preceding code doesn't lack a ';' or something.

Also, make sure the type 'Link' is defined for that part of the code
Doc Flabby - Thu Feb 28, 2008 4:35 pm
Post subject:
maybe you made this mistake of including the "utils.c" file instead of "utils.h"
Anonymous - Thu Feb 28, 2008 7:09 pm
Post subject:
Well, util.h is included at the bottom of util.c, so if you include c you also get h.
The reverse is not true as far as I know, and if I compile without util.c I get linker errors on amalloc and all the LL functions being undefined.
Anonymous - Thu Feb 28, 2008 7:24 pm
Post subject:
Also, there are plenty of places Link is in the source and it only gives an error on that one line containing Link. It never complains anywhere else about Link being undefined...I'll check it out but I don't think that's the cause.
It also gives the SAME ERROR 4 lines down, in the int LLIsEmpty line.

There is quite clearly no syntax error there, so I'm stumped.

Also I noted that util.c is not even normally included in autoturret.c... how does that even compile for grelminar without util.h or util.c?

-JP
Doc Flabby - Thu Feb 28, 2008 9:08 pm
Post subject:
Agile wrote:
Well, util.h is included at the bottom of util.c, so if you include c you also get h.
The reverse is not true as far as I know, .

Trust me on this. You are wrong.

The reverse is true. If you only include util.h the compiler will find util.c and link it in.

This is a case of counter-intuitiveness, what may seem correct and logical, is in fact wrong.

You shouldn't be including any files that end in ".c" in your source code. you should only need to include asss.h as that includes a reference to utils.h anyway.

Bascially you only need to include the interfaces (the files ending in .h) not the implementation. The Compiler will work out that for you..
Anonymous - Thu Feb 28, 2008 10:36 pm
Post subject:
Code: Show/Hide
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing  make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
dllwrap.exe --output-def outputdir/libProject2.def --driver-name c++ --implib outputdir/libProject2.a outputdir/RTZ.o  -L"C:/Dev-Cpp/lib" -L"C:/posix/Pre-built.2/lib"   -o outputdir/Project2.dll

outputdir/RTZ.o(.text+0x19):RTZ.c: undefined reference to `amalloc'
outputdir/RTZ.o(.text+0xc4):RTZ.c: undefined reference to `LLAdd'
outputdir/RTZ.o(.text+0xdb):RTZ.c: undefined reference to `LLCount'
outputdir/RTZ.o(.text+0x139):RTZ.c: undefined reference to `LLSize'
outputdir/RTZ.o(.text+0x172):RTZ.c: undefined reference to `LLCount'
outputdir/RTZ.o(.text+0x1d0):RTZ.c: undefined reference to `LLSize'
outputdir/RTZ.o(.text+0x2e1):RTZ.c: undefined reference to `LLInit'
outputdir/RTZ.o(.text+0x397):RTZ.c: undefined reference to `LLEmpty'
collect2: ld returned 1 exit status

dllwrap.exe: no export definition file provided.
Creating one, but that may not be what you want
dllwrap.exe: c++ exited with status 1

make.exe: *** [outputdir/Project2.dll] Error 1

Execution terminated

Anonymous - Thu Feb 28, 2008 10:37 pm
Post subject:
^compiled with asss.h and without util.c
Doc Flabby - Fri Feb 29, 2008 7:51 am
Post subject:
Agile wrote:
Code: Show/Hide
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing  make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
dllwrap.exe --output-def outputdir/libProject2.def --driver-name c++ --implib outputdir/libProject2.a outputdir/RTZ.o  -L"C:/Dev-Cpp/lib" -L"C:/posix/Pre-built.2/lib"   -o outputdir/Project2.dll

outputdir/RTZ.o(.text+0x19):RTZ.c: undefined reference to `amalloc'
outputdir/RTZ.o(.text+0xc4):RTZ.c: undefined reference to `LLAdd'
outputdir/RTZ.o(.text+0xdb):RTZ.c: undefined reference to `LLCount'
outputdir/RTZ.o(.text+0x139):RTZ.c: undefined reference to `LLSize'
outputdir/RTZ.o(.text+0x172):RTZ.c: undefined reference to `LLCount'
outputdir/RTZ.o(.text+0x1d0):RTZ.c: undefined reference to `LLSize'
outputdir/RTZ.o(.text+0x2e1):RTZ.c: undefined reference to `LLInit'
outputdir/RTZ.o(.text+0x397):RTZ.c: undefined reference to `LLEmpty'
collect2: ld returned 1 exit status

dllwrap.exe: no export definition file provided.
Creating one, but that may not be what you want
dllwrap.exe: c++ exited with status 1

make.exe: *** [outputdir/Project2.dll] Error 1

Execution terminated


In this case the file has compiled correctly. The problem is the linking is messed up.
Dr Brain - Fri Feb 29, 2008 8:02 am
Post subject:
add util.o to your linker settings.
Anonymous - Fri Feb 29, 2008 4:20 pm
Post subject:
OK, that did it $
I'm wondering now why the linking failed in the first place? What could have caused that?
Anonymous - Fri Feb 29, 2008 5:14 pm
Post subject:
Lol, nobody told me about this thread:
http://forums.minegoboom.com/viewtopic.php?t=7389

From there I found this link:
http://wiki.minegoboom.com/index.php/Installing_New_Modules#With_Dev_C.2B.2B

This not only is a great tutorial that solved my every problem, it also made me realize I never had to download posix pthread stuff because it was already there in windeps folder.
As a result of doing this correctly my dll file is 1/5th the size it was doing things my way.

I should be pretty much set from now on, thanks everyone and look forward to RTZ zone coming soon.

PS Special Thx 2 smong,
-Agile
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group