Questions tagged [gcc-pedantic]

1

votes
0

answer
121

Views

-Wno-pedantic ignored on older gcc

I have a C++ application where I am using zero-arguments-variadic macros. However, I don't really like the standard conforming solution posted here on SO in various answers, but rather keep the GCC specific ##__VAR_ARGS__. I'd like to catch as much warnings as possible though. My build system is mes...
flowit
0

votes
1

answer
14

Views

Will -Wpedantic do anything when compiling with a non-extension -std?

If I compile my C or C++ code with GCC, using -std=c99 or -std=c++11 or some other proper ISO standard rather than a GNU extension - will -Wpedantic issue more warnings that I would usually get? e.g. With -W, -Wall or -Wall -Wextra?
einpoklum
1

votes
1

answer
311

Views

-Wpedantic wrong type argument to increment after casting

I have a code like while (n--) { *((char*)dest++) = *((char*)src++); } where dest and src are void pointers and n a size. The goal is to re-implement a memcpy function. When compiling this code with gcc, everything works great, but when I add the -Wpedantic flag I have four warnings 'wrong type argu...
Thüzhen
1

votes
1

answer
11.9k

Views

ISO C90 forbids mixed declarations and code because of arrays. How do I fix this?

I tried compiling it using -gcc and it worked as intended but when added with -pedantic, it won't compile. I'm still quite a beginner in programming and it is the first time I encountered this problem so it is quite a problem to me. Here is the code that is causing the error: char *exercise[5]={'swi...
kenneth
2

votes
2

answer
309

Views

scope g++ pedantic compile

Is it possible to restict the -pedantic switch for certain files? For example I compile stuff using alsa-lib, which I refer with standard #include however -pedantic panics on this file. I am willing and interested in correcting warning and oddities in my own code, but not in alsa and other unrelat...
Eric
2

votes
1

answer
232

Views

Pedantic raising error when linking PAPI

I am trying to build some project that uses the PAPI 5.4.3.0 library, in an Arch Linux x86_64. For simplicity sake, I reproduced the things that I don't understand in these two files: A.cpp #include 'string.h' #include 'papi.h' int main() { } B.cpp #include 'papi.h' #include 'string.h' int main() {...
yZaph
5

votes
2

answer
1.9k

Views

C - control reaches end of non-void function

I'm writing a threading program, and the pthread_create method requires a void* function. I'm getting the 'control reaches end of non-void function' warning, and I understand why (because I don't have any official return statement)- my question is really just what should I return in this case? Is i...
user3475234
2

votes
1

answer
639

Views

static_cast / float / bitset / const weirdness

Just a few hours ago, the following question came up: Variable cannot appear in a constant-expression Luckily for the OP, the answer provided did solve his problem, but I cannot reproduce the solution. I've attempted to simplify the code even more and I am now stuck with the following: #include int...
stefan
1

votes
1

answer
120

Views

Forward define struct AND type without any warnings

Our universitie's homework submission system has - instead of focusing on programming skills - set ridiculous and impractical requirements on submissions. To bypass that, I use preprocesor and few other tricks to merge my homework solution into one file (one of the requirements). Another requirement...
Tomáš Zato
2

votes
1

answer
1.3k

Views

Function to read a key without waiting for LF

I'm looking throughout the Internet in search of some function that will read a key from keyboard without waiting for LF (like getch() from conio.h). Unfortunately I have to compile it with gcc using switches -ansi and -pedantic, which makes getch() useless to me. Maybe you know some other function...
Sushi271
8

votes
2

answer
141

Views

Ambiguous constructor taking std::reference_wrapper when compiling with -pedantic

I have a class with both a copy constructor and a constructor taking a std::reference_wrapper: #include #include class Class { public: Class() { std::cout
zennehoy
2

votes
1

answer
949

Views

gcc: fixing -pedantic “unnamed structure” warning

I'm trying to get some code from elsewhere (specifically, here), to compile without any warnings when gcc is given the -pedantic flag. The only problem is this bit of code: struct __attribute__ ((aligned(NLMSG_ALIGNTO))) { struct nlmsghdr nl_hdr; /* Unnamed struct start. */ struct __attribute__ ((_...
Matthew Cline
1

votes
1

answer
79

Views

Why would certain deprecated classes NOT generate a warning while compiling with g++?

I noticed today that one of my header files was still using an auto_ptr template. I am using -std=c++11 to make sure to compile in C++11 and -pedantic and -Werror to detect deprecated usage. So I would imagine that I should have had an error while compiling that header since auto_ptr is marked as de...
Alexis Wilke
3

votes
3

answer
948

Views

How to traverse an array parameter as void pointer

I have similar 'generic' procedure like qsort, which has a void pointer (pointing at an array) and also a function pointer parameter. This function should work on any type of array. Example: void do_something(void * array, int count, int size, void (*test)(const void*)){ int i; for(i=0; i
Aaron