How can I use external defines such as LONG_MIN and LONG_MAX in ARM assembler code?
Let's say my_arm.h looks like this:
int my_arm(int foo);
Let's say I have a my_main.c as follows:
...
#include <limits.h>
#include "my_arm.h"
...
int main (int argc, char *argv[])
{
int foo=0;
...
printf("My arm assembler function returns (%d)...
The following is designed to take a variable length constant char and print it out in a nice format for logging. I am certain readers will have suggestions on how this can be improved, and I'd welcome it.
What puzzles me is that I expected it would be necessary to free() the returned static char each time ToHexString() is called. Inst...
I have been programming iPhone SDK for around 6 months but am a bit confused about a couple of things...one of which I am asking here:
Why are the following considered different?
if (varOrObject == nil)
{
}
vs
if (nil == varOrObject)
{
}
Coming from a perl background this is confusing to me...
Can someone please explain why on...
I want to add a toolbar and know which tool was clicked. I'd also like to be able to change the toolbar's buttons' bitmap after theyve been created MSDN is fairly breif on all of this. Thanks
...
Hello,
In the code snippet, I expected a segmentation fault as soon as trying to assign a value to count[1]. However the code continues and executes the second for-loop, only indicating a segmentation fault when the program terminates.
#include <stdio.h>
int main()
{
int count[1];
int i;
for(i = 0; i < 100; i...
In C I have a pointer that is declared volatile and initialized null.
void* volatile pvoid;
Thread 1 is occasionally reading the pointer value to check if it is non-null. Thread 1 will not set the value of the pointer.
Thread 2 will set the value of a pointer just once.
I believe I can get away without using a mutex or condition ...
I have debugging functions that are called in just about every function of a large program. They are conditionally turned on by a defined macro variable. I don't want these showing up in call graphs, since I can be fairly sure that every function has them. Is there a way to exclude the function from the graph
/*! Step 3:
* @callgrap...
Which socket, the clientSocket = accept() or the listen(socket), do you setsockopt SO_KEEPALIVE on to get the connection to clients not to drop?
...
/* Bit Masking */
/* Bit masking can be used to switch a character between lowercase and uppercase */
#define BIT_POS(N) ( 1U << (N) )
#define SET_FLAG(N, F) ( (N) |= (F) )
#define CLR_FLAG(N, F) ( (N) &= -(F) )
#define TST_FLAG(N, F) ( (N) & (F) )
#define BIT_RANGE(N, M) ( BIT_POS((M)+1 - (N))-1 << (N) )
#define BIT_SHIFTL(B, N) ( (unsi...
I know there is one for multi processes
waitpid(-1,WNOHANG,NULL)
that is non-blocking function call to check if there is any child process currently working on
But is there any similar lib function to check for multithread?
All i want to do is check if there is any thread currently on, if not reset some global values.
...
I know this is an OS function. But is there a way of increasing your overall stack or heap size through C? sbrk() is used to change the size of data segment right? Does this imply both stack and heap?
...
I saw this bit of code in another thread
void foo {
int *n = malloc(sizeof(int));
*n = 10;
n++;
printf("%d", *n);
}
The mistake here is obvious. n isn't being dereferenced.
There is a memory leak.
Let's assume there is a garbage collector working here. The reference count to our initial value of n is zero now because n isn't...
Are there any widely used I/O stream abstraction layers for plain C?
By an I/O stream abstraction layer I mean any layer that at least allows the creation of custom read/write functions. For C++, there's the standard iostream and boost::iostreams. For glibc users, there's a possibility to use custom streams. These won't do any good if t...
In Kylix TEvent.WaitFor(Timeout) method only accepts Timeout of $FFFFFFFF, otherwise it generates an error. Internally it uses sem_wait function which doesn't have a timeout parameter. It there any way around this? I need to set a timeout parameter.
...
The title says it all. Recently I was debugging a project and the debugger (GDB 7.1) crashed all of a sudden, because of an endless recursion while trying to print a graph structure. At first I couldn't even imagine that a debugger could crash (a stable version) but it had. So it's really interesting to me, have you ever crashed a debugg...
I am writing a fuzzer that using the system() function and I need to copy:
char a[1100]; /* full of A's with null ending */
into:
char tmp[10000];
I used:
sprintf(tmp, "%s", a);
When I printf tmp there is nothing printed. What am I doing wrong?
...
Here is an interview question that I saw on some forum. I've been trying to figure out how it works but I don't quite get it. Could somebody explain how it works?
Q: Given a pointer to member a within a struct, write a routine that returns a pointer to the struct.
struct s
{
...
int a;
…
};
struct s *get_s_ptr(int *a_ptr)
...
I'm wondering what the stencil buffer is and what it can do. Thanks
...
HellO,
I want to write a binary file format viewer for windows which can operate on both PE & ELF files. Similar to the ones already there:
PE Explorer http://www.pe-explorer.com/
PE VIew: http://www.magma.ca/~wjr/
PEBrowse Professional http://www.smidgeonsoft.prohosting.com/pebrowse-pro-file-viewer.html
I've reasons why I want to ...
I have some very large C files, having lots of functions. I need to trace the execution path at run time. There is no way I can trace it through debugging as its a hypervisor code currently running over qemu and doing a lot of binary translations.
Can anyone point me to some script in Perl or Python which can add a printf at the startin...