ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: Alexey Morozov <morozov@novosoft.ru>
To: community@altlinux.ru
Subject: [Comm] Знатокам gcc (3.2, C++)
Date: Mon, 28 Oct 2002 19:50:52 +0600
Message-ID: <20021028135052.GZ19060@bebi.novosoft.ru> (raw)

В задаче имеется:
1. библиотека, написанная на C (libpopt)
2. код на C++, ее использующий

Постановка задачи:

имеется C'шная функция, принимающая в качестве аргумента коллбэк и дергающая
его (при определенных условиях):
/* ------------------- test_lib.c ------------ */
void some_func(void (*callback_func)(void))
{
   callback_func();
}
/* ------------------ end of test_lib.c ---------- */

С++-ный код коллбэка и функции, инициирующей вызов some_func:
/* ------------------- test.cc --------------- */
#include <iostream>
using namespace std;
struct A {};
void callback_func(void)
{
    throw A();
}

extern "C" {
    void some_func(void (*callback)(void));
}
int main(void)
{
   try {
       some_func(callback_func);
   } catch (...) {
       cerr << "An exception caught" << endl;
   }
}
/* ----------------- end of test.cc --------------*/

Проблема: происходит аварийное завершение указанной программы (abort),
как если бы брошенный exception не соответствовал throw-спецификации.

Вопрос: как бы это обойти, и таки поймать в main брошенный в коллбэке
эксепшн?

Повторю, все происходит на gcc-3.2.1, менять библиотечную функцию по
условию задачи нельзя.



             reply	other threads:[~2002-10-28 13:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-28 13:50 Alexey Morozov [this message]
2002-10-28 14:04 ` Sergey Vlasov
2002-10-28 18:45   ` Alexey Morozov
2002-10-28 18:10     ` Sergey Vlasov
2002-10-29  6:06       ` Alexey Morozov
2002-10-29  9:07         ` [Comm] [JT] " W.Kondratev
2002-10-29  9:12           ` Leonid Sysoletin
2002-10-29  9:28             ` W.Kondratev
2002-10-29 12:37         ` [Comm] " Sergey Vlasov
2002-10-30 16:56           ` Alexey Morozov
2002-10-29 17:51         ` Alexey Voinov
2002-10-29 18:08           ` Sergey Vlasov
2002-10-29 21:07             ` Alexey Voinov
2002-10-29  9:40   ` Valentin Nechayev
2002-10-29 12:51     ` Sergey Vlasov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021028135052.GZ19060@bebi.novosoft.ru \
    --to=morozov@novosoft.ru \
    --cc=community@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git