Skip to contentSkip to conversation

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

PATCH Superseded Jan Vermaete 3 participants 5 messages Aug 8, 2025 – Aug 11, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

see C17 (ISO/IEC 9899:2018)

---
 documentation/sdk-manual/working-projects.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
documentation/sdk-manual/working-projects.rst +2 -1
index 4236bcec2..7df73b1b1 100644
@@ -56,9 +56,10 @@ project:
 
          #include <stdio.h>
 
-         main()
+         int main()
              {
                  printf("Hello World!\n");
+                 return 0;
              }
 
    -  ``configure.ac``::
Signature · 1 line
2.39.5
#1 lore raw
Quoted 13 lines · Jan Vermaete via lists.yoctoproject.org

see C17 (ISO/IEC 9899:2018)

---
 documentation/sdk-manual/working-projects.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
documentation/sdk-manual/working-projects.rst +0 -0
index 4236bcec2..7df73b1b1 100644

documentation/sdk-manual/working-projects.rst project: · line 64

Quoted 10 lines
documentation/sdk-manual/working-projects.rst +2 -1
@@ -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

Quoted 13 lines
documentation/sdk-manual/working-projects.rst +0 -1
    -  ``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: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/docs/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

- "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

Quoted 61 lines · Khem Raj via lists.yoctoproject.org

Review

Quoted 9 lines · Jan Vermaete via lists.yoctoproject.org

see C17 (ISO/IEC 9899:2018)

---
 documentation/sdk-manual/working-projects.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/documentation/sdk-manual/working-projects.rst

Quoted 4 lines

index 4236bcec2..7df73b1b1 100644

documentation/sdk-manual/working-projects.rst project: · line 64

Quoted 10 lines
documentation/sdk-manual/working-projects.rst +2 -1
@@ -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

Quoted 7 lines
documentation/sdk-manual/working-projects.rst +0 -1
    -  ``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: [email protected] 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=
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

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

Quoted 70 lines · Etienne Cordonnier

- "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

Quoted 48 lines · Khem Raj via lists.yoctoproject.org

Review

Quoted 9 lines · Jan Vermaete via lists.yoctoproject.org

see C17 (ISO/IEC 9899:2018)

---
 documentation/sdk-manual/working-projects.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/documentation/sdk-manual/working-projects.rst

Quoted 4 lines

index 4236bcec2..7df73b1b1 100644

documentation/sdk-manual/working-projects.rst project: · line 64

Quoted 10 lines
documentation/sdk-manual/working-projects.rst +2 -1
@@ -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

Quoted 7 lines
documentation/sdk-manual/working-projects.rst +0 -1
    -  ``configure.ac``::
--

2.39.5

Quoted 3 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#7447):

Quoted 10 lines

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: [email protected]
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=
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw

"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.

Quoted 85 lines · jan vermaete

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

Quoted 75 lines · Etienne Cordonnier

- "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

Quoted 52 lines · On Sat, Aug 9, 2025 at 4:48 AM Khem Raj via lists.yoctoproject.org…

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=>
<[email protected]>

Review

Quoted 9 lines · wrote:

see C17 (ISO/IEC 9899:2018)

---
 documentation/sdk-manual/working-projects.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/documentation/sdk-manual/working-projects.rst

Quoted 4 lines

index 4236bcec2..7df73b1b1 100644

documentation/sdk-manual/working-projects.rst project: · line 64

Quoted 10 lines
documentation/sdk-manual/working-projects.rst +2 -1
@@ -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

Quoted 6 lines

--
2.39.5

Quoted 3 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#7447):

Quoted 10 lines

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: [email protected]
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=
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-