* [devel] volatile void для ф-ции
@ 2006-09-09 11:51 Slava Semushin
2006-09-09 12:25 ` Damir Shayhutdinov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Slava Semushin @ 2006-09-09 11:51 UTC (permalink / raw)
To: devel; +Cc: Yuriy Kashirin
Здравствуйте!
Пытаюсь восстановить собираемость netris с -Werror. Наткнулся на
множественные предуреждения типа:
proto.h:64: warning: type qualifiers ignored on function return type
proto.h:65: warning: type qualifiers ignored on function return type
При этом в proto.h:
64 ExtFunc volatile void die(char *msg);
65 ExtFunc volatile void fatal(char *msg);
И в util.c:
263 ExtFunc volatile void die(char *msg)
264 {
265 perror(msg);
266 exit(1);
267 }
268
269 ExtFunc volatile void fatal(char *msg)
270 {
271 fprintf(stderr, "%s\n", msg);
272 exit(1);
273 }
Вопрос простой: как это правильно исправить? Также хотелось бы узнать
почему volatile и void не ужились вместе.
Сейчас просто удалил volatile везде и предупреждения пропали.
Насколько понимаю, volatile здесь вообще ненужен.
Также попутно возник вопрос чисто программерский: имеет ли смысл
определять ф-ции наподобие приведённых здесь die() и fatal(), чтобы
потом везде не писать perror(); exit() и fprintf(); exit() ? Есть ли
какие-нибудь минусы в таком подходе?
Спасибо заранее!
--
+ Semushin Slava | php-coder @ ngs.ru
+ ALT Linux Team | php-coder @ altlinux.ru
+ Expand QA Team | vsemushin @ swsoft.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [devel] volatile void для ф-ции
2006-09-09 11:51 [devel] volatile void для ф-ции Slava Semushin
@ 2006-09-09 12:25 ` Damir Shayhutdinov
2006-09-14 0:21 ` Serge Pavlovsky
2006-09-14 0:37 ` Serge Pavlovsky
2 siblings, 0 replies; 4+ messages in thread
From: Damir Shayhutdinov @ 2006-09-09 12:25 UTC (permalink / raw)
To: ALT Devel discussion list
> Также попутно возник вопрос чисто программерский: имеет ли смысл
> определять ф-ции наподобие приведённых здесь die() и fatal(), чтобы
> потом везде не писать perror(); exit() и fprintf(); exit() ? Есть ли
> какие-нибудь минусы в таком подходе?
Ну то что это фактически err(3) и warn(3), а значит, переизобретенный велосипед.
ИМХО, если в программе много раз используется exit (и его аналоги типа
err/errx), это просто замаскированная проблема с анализом возвращаемых
значений.
Как правило, такой код невозможно повторно использовать во всяких
демонах, которые должны выживать в ситуациях и похуже, чем
невозможность открытия определенного файла (или для чего там обычно
используется err/exit).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [devel] volatile void для ф-ции
2006-09-09 11:51 [devel] volatile void для ф-ции Slava Semushin
2006-09-09 12:25 ` Damir Shayhutdinov
@ 2006-09-14 0:21 ` Serge Pavlovsky
2006-09-14 0:37 ` Serge Pavlovsky
2 siblings, 0 replies; 4+ messages in thread
From: Serge Pavlovsky @ 2006-09-14 0:21 UTC (permalink / raw)
To: ALT Devel discussion list
В Сбт, 09/09/2006 в 18:51 +0700, Slava Semushin пишет:
> 64 ExtFunc volatile void die(char *msg);
> 65 ExtFunc volatile void fatal(char *msg);
...
> Вопрос простой: как это правильно исправить?
void f ( x ) __attribute__ (( noreturn ));
> Также хотелось бы узнать
> почему volatile и void не ужились вместе.
потому что этот хак больше не поддерживается
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [devel] volatile void для ф-ции
2006-09-09 11:51 [devel] volatile void для ф-ции Slava Semushin
2006-09-09 12:25 ` Damir Shayhutdinov
2006-09-14 0:21 ` Serge Pavlovsky
@ 2006-09-14 0:37 ` Serge Pavlovsky
2 siblings, 0 replies; 4+ messages in thread
From: Serge Pavlovsky @ 2006-09-14 0:37 UTC (permalink / raw)
To: ALT Devel discussion list
В Сбт, 09/09/2006 в 18:51 +0700, Slava Semushin пишет:
> 64 ExtFunc volatile void die(char *msg);
> 65 ExtFunc volatile void fatal(char *msg);
...
> Вопрос простой: как это правильно исправить?
void f ( xxx ) __attribute__ (( noreturn ));
> Также хотелось бы узнать
> почему volatile и void не ужились вместе.
deprecated gcc extension
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-09-14 0:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-09 11:51 [devel] volatile void для ф-ции Slava Semushin
2006-09-09 12:25 ` Damir Shayhutdinov
2006-09-14 0:21 ` Serge Pavlovsky
2006-09-14 0:37 ` Serge Pavlovsky
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/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 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git