Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples require getopt header file to avoid 'optind' undeclared error #789

Merged
merged 1 commit into from
Sep 22, 2016
Merged

Examples require getopt header file to avoid 'optind' undeclared error #789

merged 1 commit into from
Sep 22, 2016

Conversation

julien-lecomte
Copy link
Contributor

@julien-lecomte julien-lecomte commented Sep 9, 2016

Configuration on Linux 3.19.0-49-generic #55~14.04.1-Ubuntu x86_64 fails on C files in the examples directory because of missing getopt.h include.

CFLAGS="--std=c99 -g -O2" CXXFLAGS="--std=c++11 -g -O2" ./configure --no-download --disable-ssl --disable-sasl --prefix=/usr/local
(...)
make[1]: Entering directory `/home/julien/dev/github/librdkafka/examples'
gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith --std=c99 -g -O2     -I../src rdkafka_example.c -o rdkafka_example  \
                ../src/librdkafka.a -lpthread -lz   -lcrypto   -lrt
rdkafka_example.c: In function ‘main’:
rdkafka_example.c:303:2: warning: implicit declaration of function ‘getopt’ [-Wimplicit-function-declaration]
  while ((opt = getopt(argc, argv, "PCLt:p:b:z:qd:o:eX:As:")) != -1) {
  ^
rdkafka_example.c:311:12: error: ‘optarg’ undeclared (first use in this function)
    topic = optarg;
            ^
rdkafka_example.c:311:12: note: each undeclared identifier is reported only once for each function it appears in
rdkafka_example.c:478:6: error: ‘optind’ undeclared (first use in this function)
  if (optind != argc || (mode != 'L' && !topic)) {
      ^
make[1]: *** [rdkafka_example] Error 1

@edenhill edenhill merged commit 67b0f8c into confluentinc:master Sep 22, 2016
@edenhill
Copy link
Contributor

Thanks!

@julien-lecomte julien-lecomte deleted the getopt_fix branch September 22, 2016 20:40
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.

2 participants