Well, I wrote the function also, so I can change if, if need be. For the READ case, this pointer holds the return value. For the WRITE case, this variable is the pointer to the data we wish to write. For the CLEAR case, it is ignored. So, this should work:
status = EEPROM_IO(0, (void *)0...
That is what I have done. But it seems a waste of a variable and for some reason, the "(void *)0" seems to work. Do you know what it actually is doing? Am I just getting lucky?
The function itself is defined as:
int EEPROM_IO(unsigned int addr, unsigned int *dataptr, unsigned int len, int dir);
The variable "dataptr" is used to hold the returned value when the EEPROM is read, but when written, sometimes it would be very useful (clearing the EEPROM, for example)...
Hi,
Looking through some code, I found a function of the format:
int function (parms..., (void *)0, parms...);
Is this legal? I have a need to pass a constant to a function and I really don't want to define a variable to hold it. I have a function that will either read or write a device...
Hi all,
I am in the process of reworking some of my code so that some of the more resuable functions are collected into libraries that will be linked in with multiple applications. One of these functions is a serial port driver and the way it is set up, it requires access to several flags and...
Thanks for all the replies. I think I like option #2.5 as well. However, I have always tried to keep one header file with one C file - it sounds like you are implying that this is not the best case? I don't quite know what you mean by "subsystem root", though. Could you explain?
Also, the...
Hi everyone,
I hope this isn't too elementary for everyone, but what is the absolute strictest "proper" way to declare a C function and to access it in a separate file? Assume I have been sent to a military Catholic school for C programmers :-) (Actually, we're looking at DO-178, something...
Sorry, about the original post - I think I was less than clear. I ONLY an referring to a constant declaration. The reason I ask is that our coding standards for DO-178B recommend using "const" over "#define" and I had always used all caps for #define, but not const. This is probably a very...
Hi everyone,
Please forgive the simple question, but if I have a declaration, such as:
const int UPPER_LIMIT = 127;
is the *best* policy to have it in caps? I usually do it in:
#define UPPER_LIMIT 127
and am wondering if the same thing should apply to a const variable?
Thoughts?
Jason
Thanks for the reply. I will probably put the #define as you show. Please note that I am not intentionally *limiting* the scope, I just like having it physically close together. My question, I guess, was more about what is "proper" programming procedure and if:
int function(int var)
#define...
Hi everyone,
Sometimes, I have need for a #define that really only applies to a single subroutine, so I would like to keep it with that routine. In general, I believe that #defines go at the top of a C file, so is there a good "proper" way to place the #define within the C routine? Should I...
OK, I think I am getting closer to figuring this out - thanks! But if I am right, this declares an array of 10 pointers. What I want to do is declare a "pointer to an array of character arrays, each of which is 10 characters (max) long". The idea being I would like to store a single pointer...
Hi everyone,
Sorry if this is too simple, but I am trying to figure out how to access an array of strings, using an index for the string. I have:
typedef struct
{
PARMTYPE parmtype;
_iq* parmptr;
int num_indices;
const char *(indices[10]);
// const char *indices;
} PARMTAB;
and I...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.