File fix_getopt_declaration.patch of Package qflow
From da3c6e8e0ca280607e99107c9a593fac91dc37d6 Mon Sep 17 00:00:00 2001
From: StefanBruens <stefan.bruens@rwth-aachen.de>
Date: Thu, 31 Jul 2025 13:21:30 +0200
Subject: [PATCH] Replace inconsistent getopt declaration with unistd header
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The `getopt()` declaration does not match the actual function signature,
the parameters are omitted. Use unistd.h as done in other places already.
At least current GCC rightfully complains:
`error: too many arguments to function ‘getopt’; expected 0, have 3`
---
src/blif2BSpice.c | 5 +----
src/blif2Verilog.c | 5 +----
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/blif2BSpice.c b/src/blif2BSpice.c
index 95414d6..3e7ef45 100644
--- a/src/blif2BSpice.c
+++ b/src/blif2BSpice.c
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include <math.h>
#include <ctype.h>
#include <float.h>
@@ -28,10 +29,6 @@
#define LengthOfLine 16384
#define LengthOfNodeName 512
-/* getopt stuff */
-extern int optind, getopt();
-extern char *optarg;
-
void ReadNetlistAndConvert(FILE *, FILE *, char *, FILE *,
char *, char *, char *, int);
void CleanupString(char text[]);
diff --git a/src/blif2Verilog.c b/src/blif2Verilog.c
index 78df6cb..932f819 100644
--- a/src/blif2Verilog.c
+++ b/src/blif2Verilog.c
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include <math.h>
#include <ctype.h>
#include <float.h>
@@ -25,10 +26,6 @@
#define LengthOfLine 16384
#define LengthOfNodeName 512
-/* getopt stuff */
-extern int optind, getopt();
-extern char *optarg;
-
#define INPUT 0
#define OUTPUT 1
--
2.50.0