PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 12, 2022

[FIXED] How portable is this C syntax?

 September 12, 2022     c, cross-platform     No comments   

Issue

I know GCC and probably Clang accept this syntax, but if I'm making games for the common 5 platforms (Mac, Windows, Linux, iOS, Android(Java)) but if I get C to run on Android probably by bridging Java and C, how portable is this? Should this be avoided?

I know that this is a bad funciton because simply return num*num; is enough but this syntax, should I avoid it?

int square(int num) {
    int x = ({
        int y = num;
        y*y;
    });
    return x;
}

Solution

This is not standard C. It's a GNU C extension called Statement Expressions. You should avoid it if you want maximum portability.



Answered By - Barmar
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing