V
virtual
I have a function called Set16. It takes a memory address as an
argument, and stores at that address a 16-Bit number in Big Endian
format. (I use it for networking programming). Here it is:
#include <assert.h>
#include <stdint.h>
void Set16(uint8_t *const p, uint_fast16_t const val)
{
assert(val <= 0xFFFFu);
p[0] = val >> 8;
p[1] = val & 0xFF;
}
Now the problem I have is that the assertion went off. My program was
running fine and then it just died and gave the filename and line
number of the assertion that went off. My program's been running fine
for weeks and then all of a sudden this happened.
So I did a "Find in files" for Set16, but there's a dozen places
from which this function is called, so I haven't a clue what went
wrong.
Is there any way of getting more elaborate assertions that give the
entire function call stack? For instance, something like:
Assertion failed:
In function: Set16 in frames.c at line 5
Called from: AssignChecksum in checksum.c at line 17
Called from: SendDNSLookup in net.c at line 2
Called from: main in main.c at line 27
My compiler is gcc under Linux. I'm using Codeblocks as my IDE.
argument, and stores at that address a 16-Bit number in Big Endian
format. (I use it for networking programming). Here it is:
#include <assert.h>
#include <stdint.h>
void Set16(uint8_t *const p, uint_fast16_t const val)
{
assert(val <= 0xFFFFu);
p[0] = val >> 8;
p[1] = val & 0xFF;
}
Now the problem I have is that the assertion went off. My program was
running fine and then it just died and gave the filename and line
number of the assertion that went off. My program's been running fine
for weeks and then all of a sudden this happened.
So I did a "Find in files" for Set16, but there's a dozen places
from which this function is called, so I haven't a clue what went
wrong.
Is there any way of getting more elaborate assertions that give the
entire function call stack? For instance, something like:
Assertion failed:
In function: Set16 in frames.c at line 5
Called from: AssignChecksum in checksum.c at line 17
Called from: SendDNSLookup in net.c at line 2
Called from: main in main.c at line 27
My compiler is gcc under Linux. I'm using Codeblocks as my IDE.