[ot] [gcc] __finally

R

Rafal 'Raf256' Maj

Hi,
is __finally supported yet in gcc / from with version?

Because it seems my mingw compiler (gcc based) do not recognize this
keyword.
 
P

Peter Koch Larsen

Rafal 'Raf256' Maj said:
Hi,
is __finally supported yet in gcc / from with version?

Because it seems my mingw compiler (gcc based) do not recognize this
keyword.

I must admit that I am not 100% certain as i do not know the latest g++
compilers. STill I hope it is not supported - and that it never will be.
__finally just isn't needed in C++ (that is if it means what I believe it
does)

/Peter
 
R

Rafal 'Raf256' Maj

(e-mail address removed)
__finally just isn't needed in C++ (that is if it means what I believe
it does)

It makes life a bit easier.

I make a workaround to simulate it, creating class cMustCall, that basicly
works like:


cMustCall::~cMustCall() { (*mPtr)(); }

and using ls like:

MustCall( TurnOffVideoMode() );
try { ... }
// __finally { TurnOffVideoMode();

but I need to declare a funciton for that, and unfortunetely C++ doesnt
support declaring "in-place" funcitions.. btw, perhaps it will someday?
Like
void DrawLine() {
// ...
{
void Help(int a) { ... }; // My small temporary/helper function
for (...) Help();
}
{
void Help(int a) { ... }; // My small temporary/helper function
for (...) Help();
}
}
?


And going back to cMustCall, btw, what would be declaration of a template
that can hold a pointer to any function, not just to void(); function?
 
O

Old Wolf

Rafal said:
It makes life a bit easier.

I make a workaround to simulate it, creating class cMustCall, that basicly
works like:

cMustCall::~cMustCall() { (*mPtr)(); }

and using ls like:

MustCall( TurnOffVideoMode() );
try { ... }
// __finally { TurnOffVideoMode();

It's simpler than that: put

struct foo { ~foo() { TurnOffVideoMode(); } } foo_;

just after your function to turn on the video mode.
You could even make a macro to hide the guff.
 
J

Jerry Coffin

Rafal 'Raf256' Maj wrote:

[ ... ]
but I need to declare a funciton for that, and unfortunetely C++ doesnt
support declaring "in-place" funcitions.. btw, perhaps it will
someday?

The Boost library has a 'lambda' class that allows you to do things
more or less on this order.

[ ... ]
And going back to cMustCall, btw, what would be declaration of a template
that can hold a pointer to any function, not just to void();
function?

The obvious answer would be to templatize the return type. You might
want to read _Modern C++ Design_ (by, Andrei Alexandrescu) -- it has a
section devoted to producing a class like this, but it will hold not
only pointers to functions, but also to virtually anything else that
can act like a function (e.g. a functor object).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top