G
gw7rib
If I have a function returning int, then I am free to ignore that
return value. For instance:
int fun(void);
x = fun(); // valid
fun(); // valid
If I want the former form to be invalid, I can instead make the
function of type void:
void fun(void);
x = fun(); // invalid
fun(); // valid
But supose I have a function where I don't want the return value to be
ignored. Is there any way I can do this? For instance:
unignorable int fun(void);
x = fun(); // valid
fun(); // invalid
The reason I would like such a thing is this. I am writing a program
that has "notes", and there is an option to edit the properties of a
note. One thing that can be edited is that you can associate a file
with the note, so it shows the text of that file. If you associate a
file with a note for the first time, or change the file associated
with a note, then depending on the details the note may or may not
need repainting, as its text content has changed. But, in a new
modification, you can also have an image associated with a note, which
can optionally be shown instead of the text, and if you change the
image associated with a note, or change it from showing the image to
showing the text or vice versa, it again will need repainting. At
present the routine handling the change of file name will repaint the
note if necessary. But if the user makes both changes then this can
result in the note being repainted twice, the first time incorrectly
as it has not yet taken all the changes into account. So I am
considering moving the repaint up into the edit properties routine, so
that there will be one repaint afterwards if either or both of the
subroutines say it is necessary. Since the subroutines thus lose
direct control over whether the repaint happens, I would like to
ensure that their return value (indicating whether it is required) is
not ignored to make it harder for me to mess this up.
Any thoughts welcome!
Thanks.
Paul.
return value. For instance:
int fun(void);
x = fun(); // valid
fun(); // valid
If I want the former form to be invalid, I can instead make the
function of type void:
void fun(void);
x = fun(); // invalid
fun(); // valid
But supose I have a function where I don't want the return value to be
ignored. Is there any way I can do this? For instance:
unignorable int fun(void);
x = fun(); // valid
fun(); // invalid
The reason I would like such a thing is this. I am writing a program
that has "notes", and there is an option to edit the properties of a
note. One thing that can be edited is that you can associate a file
with the note, so it shows the text of that file. If you associate a
file with a note for the first time, or change the file associated
with a note, then depending on the details the note may or may not
need repainting, as its text content has changed. But, in a new
modification, you can also have an image associated with a note, which
can optionally be shown instead of the text, and if you change the
image associated with a note, or change it from showing the image to
showing the text or vice versa, it again will need repainting. At
present the routine handling the change of file name will repaint the
note if necessary. But if the user makes both changes then this can
result in the note being repainted twice, the first time incorrectly
as it has not yet taken all the changes into account. So I am
considering moving the repaint up into the edit properties routine, so
that there will be one repaint afterwards if either or both of the
subroutines say it is necessary. Since the subroutines thus lose
direct control over whether the repaint happens, I would like to
ensure that their return value (indicating whether it is required) is
not ignored to make it harder for me to mess this up.
Any thoughts welcome!
Thanks.
Paul.