Adding p2p-rpl patch to instant contiki - c

I'm trying to apply the p2p-rpl patch offered by http://contiki-p2p-rpl.gforge.inria.fr/ to contiki, but I'm facing the following errors while trying to make the patch:
../../../core/dev/sht11.c: In function ‘sstart’:
../../../core/dev/sht11.c:74:3: error: ‘P1DIR’ undeclared (first use in this function)
../../../core/dev/sht11.c:74:3: note: each undeclared identifier is reported only once for each function it appears in
../../../core/dev/sht11.c:74:12: error: ‘P1OUT’ undeclared (first use in this function)
../../../core/dev/sht11.c: In function ‘sreset’:
../../../core/dev/sht11.c:93:3: error: ‘P1DIR’ undeclared (first use in this function)
../../../core/dev/sht11.c:94:3: error: ‘P1OUT’ undeclared (first use in this function)
../../../core/dev/sht11.c: In function ‘swrite’:
../../../core/dev/sht11.c:116:7: error: ‘P1DIR’ undeclared (first use in this function)
../../../core/dev/sht11.c:120:5: error: ‘P1OUT’ undeclared (first use in this function)
../../../core/dev/sht11.c:129:10: error: ‘P1IN’ undeclared (first use in this function)
../../../core/dev/sht11.c: In function ‘sread’:
../../../core/dev/sht11.c:142:3: error: ‘P1DIR’ undeclared (first use in this function)
../../../core/dev/sht11.c:145:5: error: ‘P1OUT’ undeclared (first use in this function)
../../../core/dev/sht11.c:147:8: error: ‘P1IN’ undeclared (first use in this function)
../../../core/dev/sht11.c: In function ‘sht11_init’:
../../../core/dev/sht11.c:215:3: error: ‘P1OUT’ undeclared (first use in this function)
../../../core/dev/sht11.c:217:3: error: ‘P1DIR’ undeclared (first use in this function)
../../../core/dev/sht11.c: In function ‘sht11_off’:
../../../core/dev/sht11.c:230:3: error: ‘P1OUT’ undeclared (first use in this function)
../../../core/dev/sht11.c:232:3: error: ‘P1DIR’ undeclared (first use in this function)
../../../core/dev/sht11.c: In function ‘scmd’:
../../../core/dev/sht11.c:256:9: error: ‘P1IN’ undeclared (first use in this function)
make: *** [obj_sky/sht11.o] Error 1

Related

I can't compile SDL_net in MinGW

Every time i try to compile SDL_net it says
SDLnet.c: In function 'SDLNet_GetLocalAddresses':
SDLnet.c:215:69: error: 'ERROR_BUFFER_OVERFLOW' undeclared (first use in this function)
if ((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == ERROR_BUFFER_OVERFLOW) {
^~~~~~~~~~~~~~~~~~~~~
SDLnet.c:215:69: note: each undeclared identifier is reported only once for each function it appears in
SDLnet.c:223:21: error: 'NO_ERROR' undeclared (first use in this function)
if (dwRetVal == NO_ERROR) {
^~~~~~~~
make: *** [SDLnet.lo] Error 1
https://www.vogons.org/viewtopic.php?f=31&t=55706#p609435
Use my Mingw guide, it's in the Google Drive link

Weird errors when calling aiGetMaterialFloat (ASSIMP, C)

I am following Assimp's documentation to retrieve properties from a struct aiMaterial type. From their documentation, this is the usage of aiGetMaterialString():
aiGetMaterialFloat(mat,<material-key>,<where-to-store>)
I was able to get the material name using aiGetMaterialString() and a propertie's color with aiGetMaterialColor(), for example, but adding this to my code:
float f = 1.0f;
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
results in:
gcc src/*.c examples/game.c -o bin/game.o -lGL -lGLEW -lSDL2 -lSDL2_image -lassimp -lm
In file included from /usr/include/assimp/scene.h:53:0,
from src/../include/mesh.h:13,
from src/mesh.c:1:
src/mesh.c: In function ‘mesh_setMaterialData’:
src/mesh.c:71:2: error: ‘pMat’ undeclared (first use in this function)
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
^
src/mesh.c:71:2: note: each undeclared identifier is reported only once for each function it appears in
src/mesh.c:71:2: error: ‘type’ undeclared (first use in this function)
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
^
src/mesh.c:71:2: error: ‘pKey’ undeclared (first use in this function)
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
^
src/mesh.c:71:2: error: ‘pOut’ undeclared (first use in this function)
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
^
src/mesh.c:71:2: error: expected ‘;’ before ‘aiGetMaterialFloatArray’
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
^
make: *** [makefile:2: ALL] Error 1
(in my code, mat is of type struct aiMaterial*).
The code I am using is also basically the same thing that's described in assimp/material.h, line 1363:
float specStrength = 1.f; // default value, remains unmodified if we fail.
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS_STRENGTH,
(float*)&specStrength);
Could anyone explain to me what I am doing wrong?
Thank you.
Edit:
This is the definition of aiGetMaterialFloat
#define aiGetMaterialFloat (pMat, type, index, pKey, pOut) \
aiGetMaterialFloatArray(pMat, type, index, pKey, pOut, NULL)
and aiGetMaterialFloatArray
ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(const C_STRUCT aiMaterial* pMat, const char* pKey, unsigned int type, unsigned int index, float* pOut, unsigned int* pMax);
I replaced what I had earlier with:
aiGetMaterialFloatArray(mat, AI_MATKEY_SHININESS, &f, NULL);
and it compiles... If I swap around the arguments on this function call I can get gcc to tell me that the 4th argument I send is actually being perceived as the 6th for aiGetMaterialFloatArray (unsigned int* pMax). I really don't know enough about macros to understand what is going on.

C library linking in linux

I have been working on a C code for which I needed some functions of libxls.h header files. I have already downloaded the corresponding files and followed the installation instruction. The files also contained a test C code (test.c) which I tried compiling. The results were as follow:
Command to compile the test.c file-
gcc test.c -lm
Results:
[root#XXXXXXX95549 test]# gcc test.c -lm
test.c:28:24: error: libxls/xls.h: No such file or directory
test.c: In function ‘main’:
test.c:33: error: ‘xlsWorkBook’ undeclared (first use in this function)
test.c:33: error: (Each undeclared identifier is reported only once
test.c:33: error: for each function it appears in.)
test.c:33: error: ‘pWB’ undeclared (first use in this function)
test.c:34: error: ‘xlsWorkSheet’ undeclared (first use in this function)
test.c:34: error: ‘pWS’ undeclared (first use in this function)
test.c:39: error: ‘WORD’ undeclared (first use in this function)
test.c:39: error: expected ‘;’ before ‘t’
test.c:53: error: ‘t’ undeclared (first use in this function)
test.c:58: error: ‘tt’ undeclared (first use in this function)
test.c:60: error: dereferencing pointer to incomplete type
test.c:63: error: dereferencing pointer to incomplete type
test.c:64: error: dereferencing pointer to incomplete type
test.c:66: error: dereferencing pointer to incomplete type
test.c:67: error: dereferencing pointer to incomplete type
test.c:68: error: dereferencing pointer to incomplete type
test.c:70: error: dereferencing pointer to incomplete type
test.c:70: error: dereferencing pointer to incomplete type
test.c:71: error: dereferencing pointer to incomplete type
To solve this problem, I copied the library files at the '/user/include' location
After which the results for same compilation commands were:
[root#XXXXXX95549 test]# gcc test.c -lm
/tmp/cc8DJETV.o: In function `main':
test.c:(.text+0x14): undefined reference to `xls_open'
test.c:(.text+0xd4): undefined reference to `xls_getWorkSheet'
test.c:(.text+0xe4): undefined reference to `xls_parseWorkSheet'
test.c:(.text+0xf0): undefined reference to `xls_getCSS'
test.c:(.text+0x49c): undefined reference to `xls_showBookInfo'
collect2: ld returned 1 exit status
Please, explain how can I rectify this problem.
The code test.c is given below:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <libxls/xls.h>
int main()
{
xlsWorkBook* pWB;
xlsWorkSheet* pWS;
FILE *f;
int i;
struct st_row_data* row;
WORD t,tt;
pWB=xls_open("files/test2.xls", "ASCII"); // "KOI8-R"
if (pWB!=NULL)
{
f=fopen ("test.htm", "w");
for (i=0;i<pWB->sheets.count;i++)
printf("Sheet N%i (%s) pos %i\n",i,pWB->sheets.sheet[i].name,pWB->sheets.sheet[i].filepos);
pWS=xls_getWorkSheet(pWB,0);
xls_parseWorkSheet(pWS);
fprintf(f,"<style type=\"text/css\">\n%s</style>\n",xls_getCSS(pWB));
fprintf(f,"<table border=0 cellspacing=0 cellpadding=2>");
for (t=0;t<=pWS->rows.lastrow;t++)
{
row=&pWS->rows.row[t];
// xls_showROW(row->row);
fprintf(f,"<tr>");
for (tt=0;tt<=pWS->rows.lastcol;tt++)
{
if (!row->cells.cell[tt].ishiden)
{
fprintf(f,"<td");
if (row->cells.cell[tt].colspan)
fprintf(f," colspan=%i",row->cells.cell[tt].colspan);
// if (t==0) fprintf(f," width=%i",row->cells.cell[tt].width/35);
if (row->cells.cell[tt].rowspan)
fprintf(f," rowspan=%i",row->cells.cell[tt].rowspan);
fprintf(f," class=xf%i",row->cells.cell[tt].xf);
fprintf(f,">");
if (row->cells.cell[tt].str!=NULL && row->cells.cell[tt].str[0]!='\0')
fprintf(f,"%s",row->cells.cell[tt].str);
else
fprintf(f,"%s"," ");
fprintf(f,"</td>");
}
}
fprintf(f,"</tr>\n");
}
fprintf(f,"</table>");
printf("Count of rows: %i\n",pWS->rows.lastrow);
printf("Max col: %i\n",pWS->rows.lastcol);
printf("Count of sheets: %i\n",pWB->sheets.count);
fclose(f);
xls_showBookInfo(pWB);
}
return 0;
}
Thanks in advance,
Got the answer to this question on the following location:
http://www.cprogramdevelop.com/2018568/
Those who might be facing the problem with libxls library can refer the above mentioned website.
cheers

Why my .c coding can't be compile in GCC?

I have a simple code in c :
#include <stdio.h>
main()
{
printf(“Hello, world! /n”);
}
but I can't compile it in GCC. The warning when i try to compile it :
1. gcc hello.c -o hello
2. hello.c: In function 'main:
3. hello.c:4:1: error: stray '\342' in program
4. hello.c:4:1: error: stray '\200' in program
5. hello.c:4:1: error: stray '\234' in program
6. hello.c:4:11: error: 'Hello' undeclared (first use in this function)
7. hello.c:4:11: note: each undeclared identifier is reported only once for each function
it appears in
8. hello.c:4:18: error: 'world' undeclared (first use in this function)
9. hello.c:4:23: error: expected ')' before '!' token
10. hello.c:4:23: error: stray '\342' in program
11. hello.c:4:23: error: stray '\200' in program
12. hello.c:4:23: error: stray '\235' in program
anyone can help me please?
You get those errors because you presumably copy and pasted that code from a formatted source. “ and ” aren't the same as ". Change them to that and the code will compile.
You should probably also follow the convention of having main defined as:
int main(void)
and therefore returning an int.
You probably also want to change /n to \n

Eclipse goto label not working in C

I am using the Eclipse CDT and I have a goto label and a FILE definition after it and when I compile the project it gives me the error: Expression expected before FILE.
Thanks in advance,
Mr. Man
EDIT:
Ok, so this is what I get from the command line:
iOS.c: In function ‘main’:
iOS.c:45: error: expected expression before ‘FILE’
iOS.c:49: error: ‘preFile’ undeclared (first use in this function)
iOS.c:49: error: (Each undeclared identifier is reported only once
iOS.c:49: error: for each function it appears in.)`
And this is what code throws the error:
fileExists:
FILE *preFile = fopen("prefix.txt","r");
As you're coding in C, you need to declare the variable at the beginning of the function:
void foo()
{
FILE* preFile;
// some code
fileExists:
preFile = fopen("prefix.txt","r");
}

Resources