Skip to content

Instantly share code, notes, and snippets.

@voiduin
Last active May 9, 2023 21:32
Show Gist options
  • Save voiduin/44886178a2fbcf4063eb8b5618920340 to your computer and use it in GitHub Desktop.
Save voiduin/44886178a2fbcf4063eb8b5618920340 to your computer and use it in GitHub Desktop.
This page show how you can use raw blocks in c

You can use code blocks within any function to separate scopes
or logically separate chunks of code and label them with a comment or label.

#include "stdio.h"
#include "stdint.h"

uint8_t GlobalVar_g = 5;

int32_t main (void)
{
  printf ("1str - global:.........%d\n", GlobalVar_g);
GeneralConfig_block:
  {
    printf ("2str - GeneralConfig:..%d\n", GlobalVar_g);
  }
TimerConfig_block:
  {
    uint8_t GlobalVar_g = 77;
    printf ("3str - TimerConfig:...%d\n", GlobalVar_g);
  }
  printf ("4str - global:.........%d\n", GlobalVar_g);
  return 0;
}

Run this code: https://onlinegdb.com/DQzIvUjXw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment