Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6810259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:11:05+00:00 2026-05-26T20:11:05+00:00

see this code #include<stdio.h> int main() { void test(void) { printf(test); return; } printf(main);

  • 0

see this code

#include<stdio.h>

int main()
{
    void test(void)
    {
        printf("test");
        return;
    }
printf("main");
return 0;
}

this coed works fine and doesnt give any warning and error. I am not getting why this happening ?
here i have written one function definition inside other function definition so is it valid?

EDIT: if yes then is there any usage of this ?

Why gcc needs to add this features as extension..there should be any usage of this isnt it ?!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:11:06+00:00Added an answer on May 26, 2026 at 8:11 pm

    Nesting of function definitions relies on a GCC extension to work. It is not described by the standard.

    If you have any desire for your code to work with other compilers then you should refrain from using such techniques. What’s more, if you collaborate with other developers, I predict that many of them will dislike the use of such non-standard constructs.

    I’m not expert with GCC but I’m fairly sure there are compiler options to disable extensions. This will allow you to get the compiler to make sure you are not writing code that won’t compile with other compilers.


    Regarding your update there are uses for nested functions. They can aid encapsulation by restricting scope and visibility. However, there is no problem that cannot be solved perfectly adequately without nested functions which I think explains why they are a rarely used GCC peculiarity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please see this piece of code: #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int i
Below is my code: #include <stdio.h> #include <math.h> void main () { int my_data[4][500];
In the next code: #include <stdio.h> int main(void) { int c; while ((c=getchar())!= EOF)
#include <stdio.h> int main(void) { printf("sizeof(char) = %zu\n", sizeof(char)); printf("sizeof('a') = %zu\n", sizeof('a')); }
I have a very simple c code: #include<stdio.h> int main() { enum boolean{true,false}; boolean
#include <stdio.h> #include <inttypes.h> int main(void) { int8_t int8; int16_t int16; int32_t int32; int64_t
I have this problem with signal() : This code compiles fine: #include <stdio.h> #include
I study this code from some book: #include <pthread.h> #include <stdio.h> /* Parameters to
This is the code that I want to try to write: #include <stdio.h> #include
I see a code as below: #include stdio.h #define VECTOR_SIZE 4 typedef float v4sf

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.