Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 26, 2025

This PR converts all C_ASSERT usages to modern static_assert throughout the XDP for Windows codebase. Modern build toolchains support static_assert which provides better error messages and is part of the C11/C++11 standards.

Changes Made

  • 72 total C_ASSERT instances converted across the entire codebase
  • Used static_assert consistently for all files (C, C++, and headers)
  • Added descriptive error messages to all static assertions for better debugging
  • Removed conditional compilation blocks that previously distinguished between C and C++ usage

Files Updated

API Headers (25 instances)

  • published/external/xdpapi.h - XDP API size assertions
  • published/external/afxdp.h - AF_XDP structure size assertions
  • All published/external/xdp/*.h headers - Extension and datapath structure assertions

Test Files (21 instances)

  • test/functional/taef/tests.cpp - API version assertions
  • test/functional/lib/tests.cpp - Buffer and connection structure assertions
  • test/pktfuzz/pktfuzz.c - Frame and buffer layout assertions
  • test/fakendis/polldpc.c - NDIS structure size assertions

Source Files (26 instances)

  • src/xdplwf/ - LWF driver alignment and offset assertions
  • src/xdp/xsk.c - XSK/XDP structure compatibility assertions
  • src/rtl/inc/xdprefcount.h - Reference counting size assertions

Example Changes

Before:

C_ASSERT(sizeof(XDP_BUFFER) == 16);

After:

static_assert(sizeof(XDP_BUFFER) == 16, "XDP_BUFFER must be exactly 16 bytes");

The conversion maintains identical functionality while providing better error messages and using modern C/C++ standards consistently across the entire codebase.

Fixes #765.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Aug 26, 2025

@mtfriesen 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 3 commits August 26, 2025 13:03
Co-authored-by: mtfriesen <3517159+mtfriesen@users.noreply.github.com>
Co-authored-by: mtfriesen <3517159+mtfriesen@users.noreply.github.com>
…mplete

Co-authored-by: mtfriesen <3517159+mtfriesen@users.noreply.github.com>
Copilot AI changed the title [WIP] Convert C_ASSERT to static_assert Convert C_ASSERT to static_assert throughout codebase Aug 26, 2025
Copilot finished work on behalf of mtfriesen August 26, 2025 13:18
Copilot AI requested a review from mtfriesen August 26, 2025 13:18
@mtfriesen
Copy link
Contributor

@copilot always use static_assert and do not use _static_assert

Co-authored-by: mtfriesen <3517159+mtfriesen@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 26, 2025

@copilot always use static_assert and do not use _static_assert

Updated all static assertions to use static_assert consistently throughout the codebase. Removed conditional compilation blocks and replaced all 72 instances of _Static_assert with static_assert as requested. See commit aa3d09b.

Copilot finished work on behalf of mtfriesen August 26, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert C_ASSERT to static_assert

2 participants