01 Aug, 2007, syn wrote in the 1st comment:
Votes: 0
Hey all.

Im having problems getting dariens buffer additions into a friends code. Heres the deal. I host with arthmoor who uses gcc 4.1.2x
Im running a modified ANSR and so is my friend, though he is hosted on a centos 4.4 server with gcc 3.3.6

I got this working in mine a while back no problems, works perfect etc.

I try it in my friends and it keeps giving me the error: structure has no member named function, file, line.

I have the define :
BUFFER *__new_buf args( (const char *file, const char *function, int line) );
#define new_buf() __new_buf(__FILE__, __FUNCTION__, __LINE__)
void BufPrintf args(( BUFFER * buffer, char * fmt, … ));

which again worked fine on my code.

what is added to new_buf is:

BUFFER *__new_buf(const char *file, const char *function, int line)


Now inside of the __new_buf function, after buffer->size = get_size(BASE_BUF);

put in the following.

/*For debugging purposes*/
buffer->file = str_dup(file);
buffer->function= str_dup(function);
buffer->line = line;

otherwise its the same, and the only problems arise from the new aditions. I of course did a full make, but no go.
It just refuses to see the define that adds those 3 items. Im kind of lost at this point. Could it be a gcc issue (as its older)?

-Syn
01 Aug, 2007, syn wrote in the 2nd comment:
Votes: 0
Sorry about how vague that kinda is, im at work at this point so I dont have shell in front of me. :rolleyes:
01 Aug, 2007, Davion wrote in the 3rd comment:
Votes: 0
Only thing I can think of is you have an old buffer code installed and you never replaced the struct for the buffer.
02 Aug, 2007, Omega wrote in the 4th comment:
Votes: 0
post the compiler error ;) thats usualy a help :)
02 Aug, 2007, syn wrote in the 5th comment:
Votes: 0
Ill post it when I get home, sorry its been crazy at work getting ready for a promotion. I did replace the struct, placed the appropriate defines in my .h's and it worked fine on my ansr on arthmoor, but still errors on my friends.

So ill gather all the setup and post it out to ya. Thanks everyone, sorry about the vagueness :-/
02 Aug, 2007, Keberus wrote in the 6th comment:
Votes: 0
Quote
Ill post it when I get home, sorry its been crazy at work getting ready for a promotion. I did replace the struct, placed the appropriate defines in my .h's and it worked fine on my ansr on arthmoor, but still errors on my friends.


I know this is a dumb question, but did you try a make clean? I have had problems before because I edited .h files and didn't make clean.

Just a thought,
KeB
02 Aug, 2007, syn wrote in the 7th comment:
Votes: 0
yup, course I did, anytime you edit an h you should.
02 Aug, 2007, Omega wrote in the 8th comment:
Votes: 0
my makefile automaticaly makes clean based on changed .h files (Good ole depends ;) )

Anyways, yeah, post the problem and I'll, (or someone else) will post a fix.
03 Aug, 2007, syn wrote in the 9th comment:
Votes: 0
Ok sorry, been hell these past couple days:

gcc -O -ggdb -Wall -c -o obj/recycle.o recycle.c
recycle.c: In function `__new_buf':
recycle.c:669: error: structure has no member named `file'
recycle.c:670: error: structure has no member named `function'
recycle.c:671: error: structure has no member named `line'


BUFFER *__new_buf(const char *file, const char *function, int line)
{
BUFFER *buffer;

if (buf_free == NULL)
buffer = alloc_perm(sizeof(*buffer));
else
{
buffer = buf_free;
buf_free = buf_free->next;
}

buffer->next = NULL;
buffer->state = BUFFER_SAFE;
buffer->size = get_size(BASE_BUF);
/*For debugging purposes*/
buffer->file = str_dup(file);
buffer->function= str_dup(function);
buffer->line = line;
buffer->string = alloc_mem(buffer->size);
buffer->string[0] = '\0';
top_buffer++;
LINK_SINGLE(buffer, next, buffer_list);
VALIDATE(buffer);

return buffer;
}


Obviously that was from recycle.c

here is the .h

/* buffer procedures */
#define new_buf() __new_buf(__FILE__, __FUNCTION__, __LINE__)
BUFFER *__new_buf args( (const char *file, const char *function, int line) );
void BufPrintf args(( BUFFER * buffer, char * fmt, … ));
BUFFER *new_buf_size args( (int size) );
void free_buf args( (BUFFER *buffer) );
bool add_buf args( (BUFFER *buffer, char *string) );
void clear_buf args( (BUFFER *buffer) );
char *buf_string args( (BUFFER *buffer) );


It doesnt matter if its there or merc or anywhere for that matter doesnt see the new define or anything. Again did a full make clean/make also
this works fine on my arthmoor account and not at all on the one using gcc 3.3.6

:/

-Syn
03 Aug, 2007, syn wrote in the 10th comment:
Votes: 0
I feel pretty stupid about now. I forgot about an addition I had to make, oy. Its been a lonnnng week :P

struct buf_type
{
BUFFER * next;
bool valid;
sh_int state; /* error state of the buffer */
sh_int size; /* size in k */
char * file; //here <–
char * function; //here <–
sh_int line; //here <–
char * string; /* buffer's string */
};


Thanks for the help heh

-Syn
04 Aug, 2007, Omega wrote in the 11th comment:
Votes: 0
yeah, thats a pretty silly mistake.

struct buf_type
{
BUFFER * next;
sh_int state; /* error state of the buffer */
sh_int size; /* size in k */
sh_int line; //here <–
char * string; /* buffer's string */
char * file; //here <–
char * function; //here <–
bool valid;
};


if you sort the struct like that, you'll save some memory per-buffer allocation.
04 Aug, 2007, syn wrote in the 12th comment:
Votes: 0
good to know, thanks

Im so exhausted im amazed I can even type anymore :)
05 Aug, 2007, Guest wrote in the 13th comment:
Votes: 0
Darien said:
struct buf_type
{
BUFFER * next;
sh_int state; /* error state of the buffer */
sh_int size; /* size in k */
sh_int line; //here <–
char * string; /* buffer's string */
char * file; //here <–
char * function; //here <–
bool valid;
};


if you sort the struct like that, you'll save some memory per-buffer allocation.


My understanding of it was that this:
struct buf_type
{
BUFFER * next;
char * string; /* buffer's string */
char * file; //here <–
char * function; //here <–
sh_int state; /* error state of the buffer */
sh_int size; /* size in k */
sh_int line; //here <–
bool valid;
};


produced better results. Going from the "top" down so to speak. Since a char* is supposed to be larger than a short, which is larger than a bool. I forget exactly why this should be the case, something to do with memory alignment.
05 Aug, 2007, Omega wrote in the 14th comment:
Votes: 0
this is because of memory allotment's, and solong as they are grouped together, they should be fine.

Its because of the overhead they create.

In anycase, a short int may be smaller then a char * i don't remember, its just how I sorted everything.
Starting with data-structures, to longs, to ints, to shorts, to char *'s to char's to bools. and it worked wonders
for me.
05 Aug, 2007, syn wrote in the 15th comment:
Votes: 0
I had started changing things to the way darien advised and I have noticed less overall ram use. Thanks allot guys :)
0.0/15