diff mbox series

sdk: The main in the C example should return an int

Message ID 20250808174828.236218-1-jan.vermaete@gmail.com
State New
Headers show
Series sdk: The main in the C example should return an int | expand

Commit Message

jan vermaete Aug. 8, 2025, 5:48 p.m. UTC
see C17 (ISO/IEC 9899:2018)

Signed-off-by: Jan Vermaete <jan.vermaete@gmail.com>
---
 documentation/sdk-manual/working-projects.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Khem Raj Aug. 9, 2025, 2:47 a.m. UTC | #1
On Fri, Aug 8, 2025 at 10:48 AM Jan Vermaete via
lists.yoctoproject.org <jan.vermaete=gmail.com@lists.yoctoproject.org>
wrote:
>
> see C17 (ISO/IEC 9899:2018)
>
> Signed-off-by: Jan Vermaete <jan.vermaete@gmail.com>
> ---
>  documentation/sdk-manual/working-projects.rst | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/documentation/sdk-manual/working-projects.rst b/documentation/sdk-manual/working-projects.rst
> index 4236bcec2..7df73b1b1 100644
> --- a/documentation/sdk-manual/working-projects.rst
> +++ b/documentation/sdk-manual/working-projects.rst
> @@ -56,9 +56,10 @@ project:
>
>           #include <stdio.h>
>
> -         main()
> +         int main()
>               {
>                   printf("Hello World!\n");
> +                 return 0;
>               }
>


I will go a step further

#include <stdio.h>

int main(void) {
    printf("Hello World!\n");
    return 0;
}

int main(void) explicitly states the function takes no parameters

>     -  ``configure.ac``::
> --
> 2.39.5
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#7446): https://lists.yoctoproject.org/g/docs/message/7446
> Mute This Topic: https://lists.yoctoproject.org/mt/114604610/1997914
> Group Owner: docs+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/docs/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Etienne Cordonnier Aug. 11, 2025, 11:59 a.m. UTC | #2
- "return 0" is optional in main after C99, so adding it is just personal
preference but not strictly necessary
- int main(void) and "int main()" are fully equivalent in C23, so changing
this is also personal preference

On Sat, Aug 9, 2025 at 4:48 AM Khem Raj via lists.yoctoproject.org
<raj.khem=gmail.com@lists.yoctoproject.org> wrote:

> On Fri, Aug 8, 2025 at 10:48 AM Jan Vermaete via
> lists.yoctoproject.org <jan.vermaete=gmail.com@lists.yoctoproject.org>
> wrote:
> >
> > see C17 (ISO/IEC 9899:2018)
> >
> > Signed-off-by: Jan Vermaete <jan.vermaete@gmail.com>
> > ---
> >  documentation/sdk-manual/working-projects.rst | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/documentation/sdk-manual/working-projects.rst
> b/documentation/sdk-manual/working-projects.rst
> > index 4236bcec2..7df73b1b1 100644
> > --- a/documentation/sdk-manual/working-projects.rst
> > +++ b/documentation/sdk-manual/working-projects.rst
> > @@ -56,9 +56,10 @@ project:
> >
> >           #include <stdio.h>
> >
> > -         main()
> > +         int main()
> >               {
> >                   printf("Hello World!\n");
> > +                 return 0;
> >               }
> >
>
>
> I will go a step further
>
> #include <stdio.h>
>
> int main(void) {
>     printf("Hello World!\n");
>     return 0;
> }
>
> int main(void) explicitly states the function takes no parameters
>
> >     -  ``configure.ac``::
> > --
> > 2.39.5
> >
> >
> >
> >
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#7447):
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_docs_message_7447&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=Wr6Y2z0KzaAxCZ5tlqzjl7FhG_g1bUuEOT6AUyTYPNRZJqCnZHTFik8OoRKFmsdV&s=VeFiakPBZ2lD6GB4rKk9wgyvPjT5NnLtMkngVkCPcUY&e=
> Mute This Topic:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_mt_114604610_7048771&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=Wr6Y2z0KzaAxCZ5tlqzjl7FhG_g1bUuEOT6AUyTYPNRZJqCnZHTFik8OoRKFmsdV&s=_YRG74nRBir2XpojvNO2_Ql-6pOAuN6ghYEWvaWkFY4&e=
> Group Owner: docs+owner@lists.yoctoproject.org
> Unsubscribe:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_docs_unsub&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=Wr6Y2z0KzaAxCZ5tlqzjl7FhG_g1bUuEOT6AUyTYPNRZJqCnZHTFik8OoRKFmsdV&s=WsKidALHg4Vou-YCH1sq9unNEfmLi-zpe-ED9HKD7tU&e=
> [ecordonnier@snap.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
jan vermaete Aug. 11, 2025, 12:16 p.m. UTC | #3
Could be, but the example as it is now in the document is not longer
compiling.

Jan Vermaete
“Success is a self-correcting phenomenom.” -- Gary Hamel


On Mon, 11 Aug 2025 at 13:59, Etienne Cordonnier <ecordonnier@snap.com>
wrote:

> - "return 0" is optional in main after C99, so adding it is just personal
> preference but not strictly necessary
> - int main(void) and "int main()" are fully equivalent in C23, so changing
> this is also personal preference
>
> On Sat, Aug 9, 2025 at 4:48 AM Khem Raj via lists.yoctoproject.org
> <raj.khem=gmail.com@lists.yoctoproject.org> wrote:
>
>> On Fri, Aug 8, 2025 at 10:48 AM Jan Vermaete via
>> lists.yoctoproject.org <jan.vermaete=gmail.com@lists.yoctoproject.org>
>> wrote:
>> >
>> > see C17 (ISO/IEC 9899:2018)
>> >
>> > Signed-off-by: Jan Vermaete <jan.vermaete@gmail.com>
>> > ---
>> >  documentation/sdk-manual/working-projects.rst | 3 ++-
>> >  1 file changed, 2 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/documentation/sdk-manual/working-projects.rst
>> b/documentation/sdk-manual/working-projects.rst
>> > index 4236bcec2..7df73b1b1 100644
>> > --- a/documentation/sdk-manual/working-projects.rst
>> > +++ b/documentation/sdk-manual/working-projects.rst
>> > @@ -56,9 +56,10 @@ project:
>> >
>> >           #include <stdio.h>
>> >
>> > -         main()
>> > +         int main()
>> >               {
>> >                   printf("Hello World!\n");
>> > +                 return 0;
>> >               }
>> >
>>
>>
>> I will go a step further
>>
>> #include <stdio.h>
>>
>> int main(void) {
>>     printf("Hello World!\n");
>>     return 0;
>> }
>>
>> int main(void) explicitly states the function takes no parameters
>>
>> >     -  ``configure.ac``::
>> > --
>> > 2.39.5
>> >
>> >
>> >
>> >
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>>
> View/Reply Online (#7447):
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_docs_message_7447&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=Wr6Y2z0KzaAxCZ5tlqzjl7FhG_g1bUuEOT6AUyTYPNRZJqCnZHTFik8OoRKFmsdV&s=VeFiakPBZ2lD6GB4rKk9wgyvPjT5NnLtMkngVkCPcUY&e=
>> Mute This Topic:
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_mt_114604610_7048771&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=Wr6Y2z0KzaAxCZ5tlqzjl7FhG_g1bUuEOT6AUyTYPNRZJqCnZHTFik8OoRKFmsdV&s=_YRG74nRBir2XpojvNO2_Ql-6pOAuN6ghYEWvaWkFY4&e=
>> Group Owner: docs+owner@lists.yoctoproject.org
>> Unsubscribe:
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_docs_unsub&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=Wr6Y2z0KzaAxCZ5tlqzjl7FhG_g1bUuEOT6AUyTYPNRZJqCnZHTFik8OoRKFmsdV&s=WsKidALHg4Vou-YCH1sq9unNEfmLi-zpe-ED9HKD7tU&e=
>> [ecordonnier@snap.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
>>
Etienne Cordonnier Aug. 11, 2025, 12:43 p.m. UTC | #4
"Could be, but the example as it is now in the document is not longer
compiling."

-> not because of a missing "return 0" or a lack of void keyword in main,
so I don't know why you mention this. I agree that adding int as return
type is necessary: "int main()", the other changes can be added, but is
purely based on personal preference and not needed to fix the build. IMO
"int main()" is better than "int main(void)", which is why this was changed
in C23.

On Mon, Aug 11, 2025 at 2:16 PM jan vermaete <jan.vermaete@gmail.com> wrote:

> Could be, but the example as it is now in the document is not longer
> compiling.
>
> Jan Vermaete
> “Success is a self-correcting phenomenom.” -- Gary Hamel
>
>
> On Mon, 11 Aug 2025 at 13:59, Etienne Cordonnier <ecordonnier@snap.com>
> wrote:
>
>> - "return 0" is optional in main after C99, so adding it is just personal
>> preference but not strictly necessary
>> - int main(void) and "int main()" are fully equivalent in C23, so
>> changing this is also personal preference
>>
>> On Sat, Aug 9, 2025 at 4:48 AM Khem Raj via lists.yoctoproject.org
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.yoctoproject.org&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=f-tqaJMvLQZsto9LmB4OqePZ_OjDN3dti7PPJVlvEhjKheIUAUdL0o3fi3YkQ4tk&s=3ohM9rWyyPHVETHCYT9vX7yeUFDmw-5TRFHoFHIPcO4&e=>
>> <raj.khem=gmail.com@lists.yoctoproject.org> wrote:
>>
>>> On Fri, Aug 8, 2025 at 10:48 AM Jan Vermaete via
>>> lists.yoctoproject.org
>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.yoctoproject.org&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=f-tqaJMvLQZsto9LmB4OqePZ_OjDN3dti7PPJVlvEhjKheIUAUdL0o3fi3YkQ4tk&s=3ohM9rWyyPHVETHCYT9vX7yeUFDmw-5TRFHoFHIPcO4&e=>
>>> <jan.vermaete=gmail.com@lists.yoctoproject.org>
>>> wrote:
>>> >
>>> > see C17 (ISO/IEC 9899:2018)
>>> >
>>> > Signed-off-by: Jan Vermaete <jan.vermaete@gmail.com>
>>> > ---
>>> >  documentation/sdk-manual/working-projects.rst | 3 ++-
>>> >  1 file changed, 2 insertions(+), 1 deletion(-)
>>> >
>>> > diff --git a/documentation/sdk-manual/working-projects.rst
>>> b/documentation/sdk-manual/working-projects.rst
>>> > index 4236bcec2..7df73b1b1 100644
>>> > --- a/documentation/sdk-manual/working-projects.rst
>>> > +++ b/documentation/sdk-manual/working-projects.rst
>>> > @@ -56,9 +56,10 @@ project:
>>> >
>>> >           #include <stdio.h>
>>> >
>>> > -         main()
>>> > +         int main()
>>> >               {
>>> >                   printf("Hello World!\n");
>>> > +                 return 0;
>>> >               }
>>> >
>>>
>>>
>>> I will go a step further
>>>
>>> #include <stdio.h>
>>>
>>> int main(void) {
>>>     printf("Hello World!\n");
>>>     return 0;
>>> }
>>>
>>> int main(void) explicitly states the function takes no parameters
>>>
>>> >     -  ``configure.ac
>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__configure.ac&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=f-tqaJMvLQZsto9LmB4OqePZ_OjDN3dti7PPJVlvEhjKheIUAUdL0o3fi3YkQ4tk&s=j2m9TmXi_dMLEfSZID4zMoJqhFaWviDSvxcmjsPHbDE&e=>
>>> ``::
>>> > --
>>> > 2.39.5
>>> >
>>> >
>>> >
>>> >
>>>
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>> Links: You receive all messages sent to this group.
>>>
>> View/Reply Online (#7447):
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_docs_message_7447&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=Wr6Y2z0KzaAxCZ5tlqzjl7FhG_g1bUuEOT6AUyTYPNRZJqCnZHTFik8OoRKFmsdV&s=VeFiakPBZ2lD6GB4rKk9wgyvPjT5NnLtMkngVkCPcUY&e=
>>> Mute This Topic:
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_mt_114604610_7048771&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=Wr6Y2z0KzaAxCZ5tlqzjl7FhG_g1bUuEOT6AUyTYPNRZJqCnZHTFik8OoRKFmsdV&s=_YRG74nRBir2XpojvNO2_Ql-6pOAuN6ghYEWvaWkFY4&e=
>>> Group Owner: docs+owner@lists.yoctoproject.org
>>> Unsubscribe:
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_docs_unsub&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=Wr6Y2z0KzaAxCZ5tlqzjl7FhG_g1bUuEOT6AUyTYPNRZJqCnZHTFik8OoRKFmsdV&s=WsKidALHg4Vou-YCH1sq9unNEfmLi-zpe-ED9HKD7tU&e=
>>> [ecordonnier@snap.com]
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>
>>>
diff mbox series

Patch

diff --git a/documentation/sdk-manual/working-projects.rst b/documentation/sdk-manual/working-projects.rst
index 4236bcec2..7df73b1b1 100644
--- a/documentation/sdk-manual/working-projects.rst
+++ b/documentation/sdk-manual/working-projects.rst
@@ -56,9 +56,10 @@  project:
 
          #include <stdio.h>
 
-         main()
+         int main()
              {
                  printf("Hello World!\n");
+                 return 0;
              }
 
    -  ``configure.ac``::