Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #120068 > unrolled thread

Set the result of void function

Started byThiago Adams <thiago.adams@gmail.com>
First post2017-09-19 14:23 -0700
Last post2017-09-20 15:30 -0700
Articles 3 on this page of 183 — 28 participants

Back to article view | Back to comp.lang.c


Contents

  Set the result of void function Thiago Adams <thiago.adams@gmail.com> - 2017-09-19 14:23 -0700
    Re: Set the result of void function Thiago Adams <thiago.adams@gmail.com> - 2017-09-19 14:38 -0700
      Re: Set the result of void function gordonb.tfand@burditt.org (Gordon Burditt) - 2017-09-19 17:16 -0500
      Re: Set the result of void function "Pascal J. Bourguignon" <pjb@informatimago.com> - 2017-09-20 00:39 +0200
        Re: Set the result of void function James Kuyper <jameskuyper@verizon.net> - 2017-09-19 22:06 -0400
          Re: Set the result of void function "Pascal J. Bourguignon" <pjb@informatimago.com> - 2017-09-20 06:51 +0200
            Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-20 10:55 +0100
              Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-20 12:11 +0100
              Re: Set the result of void function fir <profesor.fir@gmail.com> - 2017-09-20 07:17 -0700
            Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-20 11:28 +0100
            Re: Set the result of void function mark.bluemel@gmail.com - 2017-09-20 03:30 -0700
              Re: Set the result of void function fir <profesor.fir@gmail.com> - 2017-09-20 06:53 -0700
                Re: Set the result of void function Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-09-21 03:50 -0500
                  Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-21 11:00 +0100
                  Re: Set the result of void function scott@slp53.sl.home (Scott Lurndal) - 2017-09-21 12:39 +0000
                    Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-21 14:12 +0100
                      Re: Set the result of void function scott@slp53.sl.home (Scott Lurndal) - 2017-09-21 13:51 +0000
                      Re: Set the result of void function Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-09-21 08:36 -0600
                        Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-21 17:51 +0100
                          Re: Set the result of void function supercat@casperkitty.com - 2017-09-21 10:06 -0700
                            Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-22 08:51 +0200
                              Plunging innocent people into poverty (Was: Set the result of void function) gazelle@shell.xmission.com (Kenny McCormack) - 2017-09-23 09:31 +0000
                                Re: Plunging innocent people into poverty (Was: Set the result of void function) David Brown <david.brown@hesbynett.no> - 2017-09-23 12:09 +0200
                                  Re: Plunging innocent people into poverty (Was: Set the result of void function) gazelle@shell.xmission.com (Kenny McCormack) - 2017-09-23 10:25 +0000
                                Re: Plunging innocent people into poverty Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-09-23 10:43 -0600
                                  Re: Plunging innocent people into poverty supercat@casperkitty.com - 2017-09-23 10:41 -0700
                          Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-22 09:37 +0200
                            Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-22 11:27 +0100
                              Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-22 14:42 +0200
                                Re: Set the result of void function Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-09-24 12:09 +0000
                                  Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-25 08:31 +0200
                                    Re: Set the result of void function Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-09-25 03:52 -0700
                                      Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-25 13:25 +0200
                                        Re: Set the result of void function Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-09-25 04:58 -0700
                                          Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-25 14:20 +0200
                                        Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-25 13:44 +0100
                                          Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-25 15:09 +0200
                                        Re: Set the result of void function Thiago Adams <thiago.adams@gmail.com> - 2017-09-25 05:44 -0700
                                          Re: Set the result of void function Thiago Adams <thiago.adams@gmail.com> - 2017-09-25 05:58 -0700
                                            Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-25 15:15 +0200
                                              Re: Set the result of void function Thiago Adams <thiago.adams@gmail.com> - 2017-09-25 06:46 -0700
                                                Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-25 16:01 +0200
                                                  Re: Set the result of void function Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-09-25 07:18 -0700
                                                    Re: Set the result of void function Thiago Adams <thiago.adams@gmail.com> - 2017-09-25 07:55 -0700
                                                      Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-25 08:49 -0700
                                                        Re: Set the result of void function Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-09-25 09:21 -0700
                                                          Re: Set the result of void function supercat@casperkitty.com - 2017-09-25 09:51 -0700
                                                          Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-25 21:57 +0100
                                                            Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-25 15:03 -0700
                                                              Re: Set the result of void function Öö Tiib <ootiib@hot.ee> - 2017-09-25 21:34 -0700
                                                            Re: Set the result of void function Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-09-26 04:28 -0700
                                                              Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-27 08:26 +0200
                                                                Re: Set the result of void function "James R. Kuyper" <jameskuyper@verizon.net> - 2017-09-27 11:48 -0400
                                                                  Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-28 08:54 +0200
                                                                  Re: Set the result of void function gordonb.iddsu@burditt.org (Gordon Burditt) - 2017-09-28 23:33 -0500
                                                                Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-27 09:15 -0700
                                                                  Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-27 17:50 +0100
                                                                    Re: Set the result of void function jameskuyper@verizon.net - 2017-09-27 10:35 -0700
                                                                    Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-27 18:47 +0100
                                                                      Re: Set the result of void function supercat@casperkitty.com - 2017-09-27 10:52 -0700
                                                                        Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-27 11:10 -0700
                                                                        Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-28 09:10 +0200
                                                                    Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-27 11:06 -0700
                                                                      Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-27 20:01 +0100
                                                                        Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-27 12:26 -0700
                                                                          Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-27 20:38 +0100
                                                                            Re: Set the result of void function jameskuyper@verizon.net - 2017-09-27 13:00 -0700
                                                                              Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-27 21:54 +0100
                                                                                Re: Set the result of void function supercat@casperkitty.com - 2017-09-27 14:12 -0700
                                                                                Re: Set the result of void function jameskuyper@verizon.net - 2017-09-27 14:34 -0700
                                                                                  Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-27 23:16 +0100
                                                                                    Re: Set the result of void function jameskuyper@verizon.net - 2017-09-27 16:09 -0700
                                                                                      Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-28 01:12 +0100
                                                                                        Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-28 02:03 +0100
                                                                                          Re: Set the result of void function Ian Collins <ian-news@hotmail.com> - 2017-09-28 17:31 +1300
                                                                                            Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-28 09:55 +0200
                                                                                              Re: Set the result of void function Ian Collins <ian-news@hotmail.com> - 2017-09-28 21:00 +1300
                                                                                            Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-28 10:48 +0100
                                                                                              Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-28 13:20 +0200
                                                                                            Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-28 11:29 +0100
                                                                                        Re: Set the result of void function jameskuyper@verizon.net - 2017-09-27 20:27 -0700
                                                                                      Re: Set the result of void function Gareth Owen <gwowen@gmail.com> - 2017-09-29 19:30 +0100
                                                                                        Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-29 19:45 +0100
                                                                                        Re: Set the result of void function Jerry Stuckle <jstucklex@attglobal.net> - 2017-09-29 14:49 -0400
                                                                                Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-27 15:07 -0700
                                                                                Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-28 09:42 +0200
                                                                                  Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-28 13:55 +0100
                                                                                    Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-28 17:22 +0200
                                                                                      Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-28 09:14 -0700
                                                                                        Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-28 20:13 +0200
                                                                                          Re: Set the result of void function Gareth Owen <gwowen@gmail.com> - 2017-09-29 19:42 +0100
                                                                                      Re: Set the result of void function Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-09-28 09:14 -0700
                                                                                        Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-28 09:25 -0700
                                                                                        Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-28 20:17 +0200
                                                                                      Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-28 17:39 +0100
                                                                                        Re: Set the result of void function jameskuyper@verizon.net - 2017-09-28 10:10 -0700
                                                                                          Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-28 19:05 +0100
                                                                                            Re: Set the result of void function "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-09-28 14:20 -0400
                                                                                            Re: Set the result of void function Ian Collins <ian-news@hotmail.com> - 2017-09-29 07:52 +1300
                                                                                            Re: Set the result of void function jameskuyper@verizon.net - 2017-09-28 11:59 -0700
                                                                                        Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-28 18:50 +0100
                                                                                          Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-28 19:47 +0100
                                                                                        Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-28 21:57 +0200
                                                                                          Re: Set the result of void function "James R. Kuyper" <jameskuyper@verizon.net> - 2017-09-28 16:14 -0400
                                                                                          Re: Set the result of void function supercat@casperkitty.com - 2017-09-28 13:17 -0700
                                                                                          Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-28 21:23 +0100
                                                                                            Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-28 13:55 -0700
                                                                                              Re: Set the result of void function Gareth Owen <gwowen@gmail.com> - 2017-09-29 19:50 +0100
                                                                                            Re: Set the result of void function jameskuyper@verizon.net - 2017-09-28 13:57 -0700
                                                                                            Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-28 23:18 +0200
                                                                                              Re: Set the result of void function "James R. Kuyper" <jameskuyper@verizon.net> - 2017-09-28 17:38 -0400
                                                                                                Re: Set the result of void function supercat@casperkitty.com - 2017-09-28 15:54 -0700
                                                                                                Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-29 08:59 +0200
                                                                                              Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-28 14:43 -0700
                                                                                                Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-29 10:43 +0200
                                                                                                  Re: Set the result of void function supercat@casperkitty.com - 2017-09-29 07:43 -0700
                                                                                              Re: Set the result of void function Gareth Owen <gwowen@gmail.com> - 2017-09-30 19:21 +0100
                                                                                                Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-30 19:45 +0100
                                                                                          Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-28 13:31 -0700
                                                                                            Re: Set the result of void function supercat@casperkitty.com - 2017-09-28 13:41 -0700
                                                                                              Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-28 14:07 -0700
                                                                                            Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 16:25 -0700
                                                                                              Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-28 18:45 -0700
                                                                                                Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 19:54 -0700
                                                                                                  Re: Set the result of void function jameskuyper@verizon.net - 2017-09-28 20:51 -0700
                                                                                                    Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-28 22:39 -0700
                                                                                                      Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-29 09:16 -0700
                                                                                                        Re: Set the result of void function gazelle@shell.xmission.com (Kenny McCormack) - 2017-09-29 16:17 +0000
                                                                                                        Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-29 11:05 -0700
                                                                                                          Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-29 11:23 -0700
                                                                                                            Re: Set the result of void function supercat@casperkitty.com - 2017-09-29 12:15 -0700
                                                                                                            Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-29 16:04 -0700
                                                                                                              Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-29 16:44 -0700
                                                                                                                Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-30 10:04 -0700
                                                                                                                  Re: Set the result of void function supercat@casperkitty.com - 2017-09-30 10:33 -0700
                                                                                                          Re: Set the result of void function jameskuyper@verizon.net - 2017-09-29 11:26 -0700
                                                                                                            Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-29 16:03 -0700
                                                                                                      Re: Set the result of void function jameskuyper@verizon.net - 2017-09-29 09:44 -0700
                                                                                                        Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-29 11:15 -0700
                                                                                                          Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-29 11:35 -0700
                                                                                                            Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-29 16:11 -0700
                                                                                                            Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-29 16:14 -0700
                                                                                                              Re: Set the result of void function supercat@casperkitty.com - 2017-09-30 08:55 -0700
                                                                                                          Re: Set the result of void function jameskuyper@verizon.net - 2017-09-29 11:36 -0700
                                                                                                    Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-29 12:05 +0100
                                                                                                  Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-29 12:17 +0100
                                                                                                  Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-29 09:15 -0700
                                                                                        Re: Set the result of void function Ian Collins <ian-news@hotmail.com> - 2017-09-29 09:42 +1300
                                                                                          Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-28 21:55 +0100
                                                                                            Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-28 14:12 -0700
                                                                                              Re: Set the result of void function "James R. Kuyper" <jameskuyper@verizon.net> - 2017-09-28 17:22 -0400
                                                                                              Re: Set the result of void function Gareth Owen <gwowen@gmail.com> - 2017-09-29 19:50 +0100
                                                                                    Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-28 09:00 -0700
                                                                                      Re: Set the result of void function supercat@casperkitty.com - 2017-09-28 09:35 -0700
                                                                                        Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-28 10:57 -0700
                                                        Re: Set the result of void function Thiago Adams <thiago.adams@gmail.com> - 2017-09-25 10:35 -0700
                                            Re: Set the result of void function Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-09-25 06:57 -0700
                                      Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-25 16:32 +0100
                                        Re: Set the result of void function Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-09-25 08:43 -0700
                                          Re: Set the result of void function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-25 22:12 +0100
                                        Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-25 09:03 -0700
                                    Re: Set the result of void function Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-09-25 14:17 +0000
            Re: Set the result of void function "James R. Kuyper" <jameskuyper@verizon.net> - 2017-09-20 11:32 -0400
          Re: Set the result of void function fir <profesor.fir@gmail.com> - 2017-09-20 01:50 -0700
            Re: Set the result of void function David Kleinecke <dkleinecke@gmail.com> - 2017-09-20 15:56 -0700
    Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-19 23:01 +0100
      Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-20 15:40 +0200
        Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-20 08:50 -0700
          Re: Set the result of void function David Brown <david.brown@hesbynett.no> - 2017-09-20 22:52 +0200
            Re: Set the result of void function supercat@casperkitty.com - 2017-09-20 15:04 -0700
      Re: Set the result of void function supercat@casperkitty.com - 2017-09-20 07:39 -0700
    Re: Set the result of void function jameskuyper@verizon.net - 2017-09-19 15:18 -0700
      Re: Set the result of void function bartc <bc@freeuk.com> - 2017-09-20 01:21 +0100
        Re: Set the result of void function jameskuyper@verizon.net - 2017-09-19 19:40 -0700
    Re: Set the result of void function rockbrentwood@gmail.com - 2017-09-19 16:36 -0700
      Re: Set the result of void function James Kuyper <jameskuyper@verizon.net> - 2017-09-19 22:13 -0400
      Re: Set the result of void function gazelle@shell.xmission.com (Kenny McCormack) - 2017-09-22 01:48 +0000
    Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-19 19:36 -0700
    Re: Set the result of void function mark.bluemel@gmail.com - 2017-09-20 01:00 -0700
      Re: Set the result of void function fir <profesor.fir@gmail.com> - 2017-09-20 02:01 -0700
    Re: Set the result of void function Keith Thompson <kst-u@mib.org> - 2017-09-20 08:36 -0700
    Re: Set the result of void function "James R. Kuyper" <jameskuyper@verizon.net> - 2017-09-20 11:36 -0400
    Re: Set the result of void function John Bode <jfbode1029@gmail.com> - 2017-09-20 15:30 -0700

Page 10 of 10 — ← Prev page 1 … 8 9 [10]


#120102

FromKeith Thompson <kst-u@mib.org>
Date2017-09-20 08:36 -0700
Message-ID<lno9q55qmz.fsf@kst-u.example.com>
In reply to#120068
ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Thiago Adams <thiago.adams@gmail.com> writes:
>>Can I set the result of some void function and get it back?
>
>   A function that has the return type »void«
>   cannot return a result.
>
>   However, in traditional C, the return type
>   can be omitted:
>
> strcopy(s,t)
>     char *s, *t; {
>         while(*t++ = *s++);
> }
>
>   . Such a function can return something or not
>   in its body.

Yes, but in pre-1999 C omitting the return type is *exactly*
equivalent to specifying it as int.  It makes no difference in
whether you can omit a return statement or not.

Omitting the return type is a reasonable convention for a function
that's not intended to return a meaningful result, but it's a
convention that's useful only in pre-ANSI C, and possible only in
pre-1999 C.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#120103

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2017-09-20 11:36 -0400
Message-ID<07e51c43-c219-1584-0503-a7b7b8e7402d@verizon.net>
In reply to#120068
On 2017-09-20 08:14, Stefan Ram wrote:
> Thiago Adams <thiago.adams@gmail.com> writes:
>> Can I set the result of some void function and get it back?
> 
>    A function that has the return type »void«
>    cannot return a result.
> 
>    However, in traditional C, the return type
>    can be omitted:
> 
> strcopy(s,t)
>      char *s, *t; {
>          while(*t++ = *s++);
> }
> 
>    . Such a function can return something or not
>    in its body.

You should mention that the only type of something that it could return 
is "int". This mis-feature was called "implicit int", and it is one of 
the few features of C to be so widely maligned that the Committee 
decided to remove the feature, in C99.

[toc] | [prev] | [next] | [standalone]


#120109

FromJohn Bode <jfbode1029@gmail.com>
Date2017-09-20 15:30 -0700
Message-ID<d13a0200-9c4c-4b35-96fc-fd2f741eacb5@googlegroups.com>
In reply to#120068
On Tuesday, September 19, 2017 at 4:24:04 PM UTC-5, Thiago Adams wrote:
> Can I set the result of some void function and get it back?
> 

Apart from writing to a parameter or setting a global?  Which are your
choices if you insist on typing the function void.  

> 
> I ask just to see if I can put some error code in void functions.
>  

You can, you just have to be creative in how you store and access that error
code.

If a function call can result in some kind of error that you want to deal
with, the best course of action is to either have the function return that
error value directly (and type the function appropriately) or to write that
error code to an output parameter.

If you don't want to do either of those things, you can write to a global, 
but for obvious reasons (reentrancy, thread safety, etc.) that's 
discouraged.  To get around those problems, you could set up a stack or list
or heap that you insert the error code into, with some key indicating the
specific function invocation (recursion depth, thread ID, something like that).  

You can fake exception handling (badly) using a combination of setjmp()/
longjmp() or raise() or something like that.  I've toyed with setjmp()/
longjmp() a bit and it does the job, but the resulting code is 
impenetrable.  It just doesn't flow naturally.  

> Also to understand how everything works under the hood if the 
> solution is just for x86 for instance.
> 

You're really better off relying on behavior that's well-defined.

> 
> 
> 
> ----
> 
> I can do the opposite that is not set the result:
> 
> int F()
> {
>     goto END;
>     if (0)
>         return 1;
>     END:;
> }

Which results in undefined behavior.

> 
> int main()
> {
>   int i = F();
> }

[toc] | [prev] | [standalone]


Page 10 of 10 — ← Prev page 1 … 8 9 [10]

Back to top | Article view | comp.lang.c


csiph-web