Strange dev-cpp error


Just made a test in Dev-cpp of a small bit of a sender routine. I got this error:
undefined  reference to ‘__cpu_features_init’
then all removed with an practically empty main.c, again the same error.

Found this link with the solution:

the solution being: Tools->Compiler Options->Directories->Libraries — delete all what is there and voila!


Weird compiler problem


In my game the player can move blocks in four directions. While developing I used a printf() above the code that is causing problems. When I remove this printf I can no longer move boxes up, but I can move them in other directions.

I’ve also removed the printf() and called a different function. Same result, even if the function does nothing.

On the NDS it worked the same as in de emulator.

I compiled it using Eclipse and it turned out it does work when compiled in Programmers Notepad. So it’s appears to be a compile problem from Eclipse.

See images below:

C Compiles backwards


Now a little post about C that apparently compiles backwards.

If you include some files into your project, the file that is included last can’t make use of the file you included first.

Example of how I experienced this habit of C:

#include “prep.h”
#include “run.h”

… some simple code here, cause I’ve written it myself …

#include <nds.h>
#include “draw.h”
#include “button.h”

… do some things with u8 and u 16 …

This will result in the following error:
“error: expected declaration specifiers or ‘…’ before ‘u8′”

Because button.h needs nds.h, but it only is included in prep.h, apparently after button.h is compiled.
So you can remove the include of nds.h from prep.h and put it in a file that is the tiniest brick of your project! In my case I can inlude it in button.h and remove it from prep.h and main.c. Button.h with nds.h is compiled first, so prep and main can make use of the stuff of nds.h.

Prettig weekend !

Errors and (possible) solutions


working in Programmers NotePad

compile error:
error: expected specifier-qualifier-list before ‘u8’


error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘getRotCentreX_imageView’

solution: #include <nds.h>

warning: implicit declaration of function ‘run’

you have a function clled ‘run’ but no declaration of it (either in this file or in an include)

solution: most probably: include the header file where the compiler can find this ‘run’ function

error: request for member ‘videoBuffer’ in something not a structure or union

it could be accessing a member of a struct with . instead of -> for instance:

((BUTTONVIEW*) myButtonViewPtr).videoBuffer= (u16 *)myVideoBuffer;

which must be:

((BUTTONVIEW*) myButtonViewPtr)->videoBuffer= (u16 *)myVideoBuffer;

make[1]: /c/Documents: No such file or directory
make[1]: *** No rule to make target `/c/Documents’.  Stop.
“make”: *** [build] Error 2

you tried to compile outside the devkitpro folder, put the project in this folder and it might compile without problems

warning: ‘touchReadXY’ is deprecated (declared at c:/devkitPro/libnds/include/nds/arm9/input.h:89)

Replaced the deprecated touchReadXY() calls with touchRead()

Error while building example “betweenlines”


When I tried to build/make the example from contre choc, Between Lines, I got the following error:
“The procedure entry point _FreeImage_FlipVertical@4 could not be located in the dynamic link library FreeImage.dll”.

After a lot of searching on the internet and several tries of myself the solution was to copy the FreeImage.dll file to the system32 folder of your windows installation.
This dll file can be found in the grit application. Just copy and paste it 🙂

multiple definition of ‘variable’


I received this error:

Filename.cpp:54: multiple definition of `variable’
Filename.o: Filename.cpp:24: first defined here
Filename.o: In function `function()’:

I thought it was something with multiple includes. But it turned out that I should have used .c files instead of .cpp.

When I renamed all the files the error was gone.