Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 20, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 20, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 20, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 20, 2025

      Helldivers 2: Heart of Democracy update is live, and you need to jump in to save Super Earth from the Illuminate

      May 20, 2025

      Qualcomm’s new Adreno Control Panel will let you fine-tune the GPU for certain games on Snapdragon X Elite devices

      May 20, 2025

      Samsung takes on LG’s best gaming TVs — adds NVIDIA G-SYNC support to 2025 flagship

      May 20, 2025

      The biggest unanswered questions about Xbox’s next-gen consoles

      May 20, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      HCL Commerce V9.1 – The Power of HCL Commerce Search

      May 20, 2025
      Recent

      HCL Commerce V9.1 – The Power of HCL Commerce Search

      May 20, 2025

      Community News: Latest PECL Releases (05.20.2025)

      May 20, 2025

      Getting Started with Personalization in Sitecore XM Cloud: Enable, Extend, and Execute

      May 20, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Helldivers 2: Heart of Democracy update is live, and you need to jump in to save Super Earth from the Illuminate

      May 20, 2025
      Recent

      Helldivers 2: Heart of Democracy update is live, and you need to jump in to save Super Earth from the Illuminate

      May 20, 2025

      Qualcomm’s new Adreno Control Panel will let you fine-tune the GPU for certain games on Snapdragon X Elite devices

      May 20, 2025

      Samsung takes on LG’s best gaming TVs — adds NVIDIA G-SYNC support to 2025 flagship

      May 20, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»CodeSOD: A Type of Alias

    CodeSOD: A Type of Alias

    June 3, 2024

    Joe inherited some C code that left him scratching his head.

    It doesn’t start too badly:

    typedef unsigned char byte;
    typedef unsigned short word;

    This aliases two built-in types (unsigned char and unsigned short) to byte and word, respectively. This isn’t uncommon, using typedefs to give types more convenient or descriptive names is generally a good practice. The typedef is just an alias at compile time, so you’re not really changing anything, just creating an easy to reference name.

    As always, it’s worth noting that short has a minimum size, but no maximum size defined in the spec. So assuming that a word is two bytes is potentially a mistake.

    Hostinger

    But that’s not the WTF. The WTF is the next two lines, so here’s the whole snippet, for context:

    typedef unsigned char byte;
    typedef unsigned short word;
    #define byte unsigned char
    #define word unsigned short

    This creates a preprocessor macro that will replace all occurrences of byte with unsigned char, and all occurrences of word with unsigned short. This will run before compilation, and essentially be a find/replace. This means that by the time the compiler gets the code, there will be no bytes or words. So the typedef doesn’t matter- the compiler will never see the alias used.

    This code isn’t the worst abuse we’ve seen in C, by far, but it still leaves me scratching my head, trying to understand how we got here. I could understand it better if these four lines weren’t all together. One header doing a typedef, and another header doing a #define would be bad, but that’s just the life of a C programmer, as you pull together modules written by different people across different years. I could understand having that happen. But right next to each other?

    [Advertisement]
    Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleLWiAI Podcast #169 – Google’s Search Errors, OpenAI news & DRAMA, new leaderboards
    Next Article Web Application VS JMeter Reports differences

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 21, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-5011 – MoonlightL Hexo-Boot Cross-Site Scripting Vulnerability

    May 21, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    On Crafting Painterly Shaders

    Development

    CVE-2025-37985 – Linux Kernel USB Wdm Wwan Buffer Overflow

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-3958 – Withstars Books-Management-System Cross-Site Scripting Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Index types supported in Amazon Aurora PostgreSQL and Amazon RDS for PostgreSQL (B-tree)

    Databases

    Highlights

    CVE-2025-3928 – Commvault Web Server Remote Webshell Execution

    April 25, 2025

    CVE ID : CVE-2025-3928

    Published : April 25, 2025, 4:15 p.m. | 3 hours, 29 minutes ago

    Description : Commvault Web Server has an unspecified vulnerability that can be exploited by a remote, authenticated attacker. According to the Commvault advisory: “Webservers can be compromised through bad actors creating and executing webshells.” Fixed in version 11.36.46, 11.32.89, 11.28.141, and 11.20.217 for Windows and Linux platforms.

    Severity: 8.8 | HIGH

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    Rethinking The Role Of Your UX Teams And Move Beyond Firefighting

    July 29, 2024

    12 useful features Google just announced for Pixel phones, watches, and tablets

    June 11, 2024
    Salesforce AI Released APIGen-MT and xLAM-2-fc-r Model Series: Advancing Multi-Turn Agent Training with Verified Data Pipelines and Scalable LLM Architectures

    Salesforce AI Released APIGen-MT and xLAM-2-fc-r Model Series: Advancing Multi-Turn Agent Training with Verified Data Pipelines and Scalable LLM Architectures

    April 9, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.