688 views|3 replies

6069

Posts

4

Resources
The OP
 

esp-idf4.4 can execute (defalut) C11 standard function nested definition. What are the applications? [Copy link]

 This post was last edited by damiaa on 2023-6-7 10:05

I was thinking about something today, and I checked and found that esp-idf4.4 can execute (defalut) C11 standard function nested definition. What are the applications? Please help me

#include"stdio.h"
int main(void)
{
    int x=0,y=0,z=0,i=5;
    auto pt(int x,int y,int z){
        printf("x is %d,y is %d,z is %d\n",x,y,z);
        printf("x+y+z is %d\n",x+y+z);
    }
    while(i){
        x++;y+=2;z+=3;
        pt(x,y,z);
        i--;
    }
}


This post is from Domestic Chip Exchange

Latest reply

nmg
I guess programmers don't like to use this kind of additional gameplay. Afraid that some compilers are incompatible   Details Published on 2023-6-7 18:38
 
 

6069

Posts

4

Resources
2
 

Switch can also be played like this

#include <stdio.h>
int main(int argc, const char * argv[])
{
    int a = 1;
    int c = 10;
    switch(a)
    {
        // 这条case语句是合法的,并且与case 1等效
        case 1 ... 1:
            printf("a = %d\n", a);
            break;
        // 这条case语句中的范围操作符的左操作数大于右操作数,
        // 因此它是一个空条件范围,这条case语句下的逻辑永远不会被执行
        case 2 ... 5:
            puts("Hello, world!");
            break;

        case 8 ... 10:
        puts("Wow!");
            break;
        default:
            break;
    }
    char ch = 'A';
    switch(ch)
    {
        // 从'A'到'Z'的ASCII码范围
        case 'A' ... 'Z':
            printf("The letter is: %c\n", ch);
            break;
        // 从'0'到'9'的ASCII码范围
        case '0' ... '9':
        printf("The digit is: %c\n", ch);
        default:
            break;
    }
}

This post is from Domestic Chip Exchange

Comments

nmg
I guess programmers don't like to use this additional gameplay because they are afraid that some compilers will be incompatible.  Details Published on 2023-6-7 18:38
 
 
 

5218

Posts

239

Resources
3
 
damiaa posted on 2023-6-7 10:42 Switch can also be played like this #include int main(int argc, const char * argv[]) { ...

I guess programmers don't like to use this kind of additional gameplay.

Afraid that some compilers are incompatible

This post is from Domestic Chip Exchange
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle

Comments

I think it's still interesting  Details Published on 2023-6-7 20:01
 
 
 

6069

Posts

4

Resources
4
 
nmg posted on 2023-6-7 18:38 I guess programmers don’t like to use this kind of added gameplay, for fear that some compilers are incompatible

I think it's still interesting

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list