Imagine the following code:
void DoThis()
{
if (!isValid) return;
DoThat();
}
void DoThat() {
Console.WriteLine("DoThat()");
}
Is it OK to use a return inside a void method? Does it have any performance penalty? Or it would be better to write a code like this:
void DoThis()
{
if (isValid)
{
DoThat();
...
<a href="javascript:void(0)" id="loginlink">login</a>
I've seen such hrefs many times, but I don't know what exactly that means.
...
I'm writing a DLL in Delphi using the below C++ example:
USERDLL_API double process_message (const char* pmessage, const void* param)
{
if (pmessage==NULL) { return 0; }
if (param==NULL) { return 0; }
if (strcmp(pmessage,"state")==0)
{
current_state *state = (current_state*) param;
return process_state( (cu...
hello, how can i get the memory address of the value a pointer points to? in my case it is a void pointer.
just assigning it to an uint gives me this error:
Error 1 error C2440: 'return' : cannot convert from 'void *' to 'UInt32'
thanks!
...
Visual C++ is saying my void function needs a return value
I compiled this on my mac, and it worked perfectly, but now I am trying to compile this with Visual c++ (using windows 7)
Heres the build log:
Command Lines Creating temporary file
"c:\Users\Jonathan\Documents\Visual
Studio
2008\Projects\magicsquare\Debug\RSP000008229...
I'm trying to figure out what the following code in C does?
((void(*)())buf)();
where 'buf' is a char array.
...
I have the following C code in a program:
printf("Test before print_foo()");
void print_foo(char board[ROW][COL]);
printf("Test after print_foo()");
where print_foo printf's the passed in 2-D character array with proper .c and .h files imported.
Console output is only the two printf statements.
Debugging, the run-time never even step...
I'm using the ffcall (specifically the avcall package of ffcall) library to dynamically push parameters to variadic functions. i.e. we have
int blah (char *a, int b, double c, ...);
and we want to call this function with values taken from the user. To do this, we create an avcall version of the function:
int av_blah (char *a, int b...
Ive got some C++ code, that we use to serialize arbitrary data and store it into a specialized image format as metadata.
Anyways, it takes it as a void*. Can i just do a simple memcpy? Or is there a better way to do this?
...
Coming from OO (C#, Java, Scala) I value very highly the principles of both code reuse and type-safety. Type arguments in the above languages do the job and enable generic data structures which are both type-safe and don't 'waste' code.
As I get stuck into C, I'm aware that I have to make a compromise and I'd like it to be the right one...
I would like to understand which is the difference between these two programming concepts. The first represents the absence of data type and at the latter the type exists but there is no information. Additionally, I recognize that Unit comes from functional programming theoretical foundation but I still cannot understand what is the usab...
After there was a misunderstanding of "C/C++ programmers" with the a non-mentioned/existing "C/C++ language", and eventually getting the question closed, I decided to void it.
I had voted to delete it, and planned to split the question in two (C language specification, compilers and their version diffs, and C++ language specs, compilers...
Hello there,
I'm new on C++ and I'm trying to make some testing with C++ and SDL and in SDL we have a function:
SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param);
which I can pass a callback for the timer created.
But apparently it converts my instance this to *void so I can't retrieve it again on...
I have the following method, and I want to know if there is anything that can go in place default(void) below because there is a compiler error that says that void is not valid here:
private void applyDefaultsIfNecessary(ApplicationConfiguration configuration)
{
var defaults = new Dictionary<Predicate<ApplicationConfiguration>, Acti...
I'm developping an imaging library and I'm struggling with the image data datatype
Since images can have variable datatypes (8 bits per pixel, 16 bits per pixel) I thought of implementing my image data pointer to
void* pimage_data;
however void* leads to all kind of nastiness including ugly pointer arithmetics such as
pimage_data ...
Are there any hard and fast rules regarding returning boolean in a method signature to indicate a successful operation as opposed to declaring void? I find that for more critical operations in my calling method I want to know if an operation completed so I can log any issues. Is this an "inappropriate" use of boolean?
...
I'm working on trying to speed up some general data processing in C. I've written several subroutines of the form:
double *do_something(double *arr_in, ...) {
double *arr_out;
arr_out = malloc(...)
for (...) {
do the something on arr_in and put into arr_out
}
return arr_out;
}
I like this style because it's eas...
I am creating a game where where you complete shapes and the area gets filled in. However, if there is an enemy bird within your shape, it will not fill in. I want to make it so that if you do trap a bird within your shape, you will lose a life. How can I write an if statement that pretty much says if the below code doesn't take place...
i'm trying to listen to an archived radio programme file from here (via firefox):
http://www.sunriseradio.com/player/archivelist/?audionum=14/02/2010
...but it just doesn't play/work!!! just keeps giving a "javascript void" message.
any solutions or suggestions??? i really need to play that file!!!
...
How can I resolve this case of Useless use of a variable in a void context?
For example:
my $err = $soap_response->code, " ", $soap_response->string, "\n";
return $err;
I get warnings like Useless use of a variable in a void context? Why? How can I resolve it ?
...