Created
February 6, 2026 02:41
-
-
Save shelvacu/3dff4ee8e155e4485a7b7781ba84b7b4 to your computer and use it in GitHub Desktop.
Example of gcc forward parameter declaration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Compile with: gcc -Wall -std=gnu99 main.c | |
| #include <stddef.h> | |
| #include <stdlib.h> | |
| // see https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html | |
| void foo(size_t length; char buf[length], size_t length) { | |
| for (size_t i=0; i<length; i++) { | |
| buf[i] = 0; | |
| } | |
| } | |
| int main(void) { | |
| char* buf = malloc(100); | |
| foo(buf, 128); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment