php extension code must be c89 style [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I wrote a php extension: https://github.com/binpack/binpack-php, it works great and I want to submit this extension to PECL.
But they said that my code is C99 style and PHP except C89 style. I read somethings about C99 and C89.
And figure out some difference:
stdbool.h
inline vs __inline__
I think there are some problem in these 2 files:
https://github.com/binpack/binpack-php/blob/master/bin_pack.c
https://github.com/binpack/binpack-php/blob/master/bin_pack.h
I modified some of my code and used -std=gnu89 to test them. But I am not sure if there are still some problems.
My question is:
How can I test if my code is c89 style?
If anyone can point out the problems in my code, that will be great.

It won't warn about every feature not in C89, but
gcc -Wall -pedantic -std=c89 ...
is a good place to start.

Related

How to use regex in C/Where to find the files? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I want to use regex and I saw that the POSIX regular expression library provides functions but how do I include the library? Where to find the files? I googled a lot and did not find any manual.
Can anyone help me by providing a manual or a link to a manual? I am using Visual Studio Code
C by itself doesn't have regex, but there are multiple libraries providing this functionality, like:
PCRE and PCRE2 - http://www.pcre.org/
libgnurx - https://github.com/TimothyGu/libgnurx
TRE - http://laurikari.net/tre/about/
sregex - https://github.com/openresty/sregex
slre - https://github.com/cesanta/slre
liblightgrep - https://github.com/strozfriedberg/liblightgrep
RxSpencer - https://github.com/garyhouston/rxspencer
RE2 - https://github.com/google/re2/
Oniguruma - https://github.com/kkos/oniguruma
Onigmo - https://github.com/k-takata/Onigmo
Hyperscan - https://www.hyperscan.io/
And there are probably more regex libraries out there.
I have been able to compile all of the above from source for Windows using MinGW-w64.
Most commonly used are PCRE, PCRE2, libgnurx, but Oniguruma and Hyperscan are interesting alternatives.
If you're using C++ there is also std::regex or boost::regex.

Is <windows.h> in collision with "raylib.h" library [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am trying to build a game in C language using raylib library and I wanted to deploy the sleep function that is defined in library. The latter generates a problem in the build of raylib library
Let's say that you have two headers, header1.h and header2.h, both containing a function named foo. Then you can define a new header/source pair:
mynewheader.h:
int header2_foo(int n);
mynewheader.c:
#include <header2.h>
int header2_foo(int n) {
return foo(n);
}
Of course, you can choose any prefix you want, or rename the function completely for that matter. This kind of mimics the namespace feature in C++.
If sleep is the only function you need from Windows.h then use _sleep() from stdlib.h instead. Check this MSDN discussion for further reference.

dynamic semantic errors checking [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I read that dynamic semantic errors cannot be detected by the C compiler as semantic analysis phase catches only static semantic errors.
Then which component of C compiler does the checking of dynamic semantic errors?
which component of C compiler does the checking of dynamic semantic errors?
No phase. They are detected at runtime, if at all, by definition.
By dynamic semantic error, I mean accessing an index of array (out of bounds).
There is no such check in C.
I read somewhere that compiler generates code for checking dynamic semantic errors.
Not in C.
I am not sure what it meant.
Nothing in the case of C. Possibly you were reading about some other language. In any case the dynamic semantic check is still executed at runtime, not by any compiler phase.
As for my understanding the dynamic semantic errors can be discovered only during the runtime. C does not have any mechanisms for it, as C does not allow any dynamic semantics at all :) It is not an interpreted or JIT comiled language.
If you provide a real example of the dynamic semantic error in C, it will clarify what you actually mean

How do you add/specify predefined macros for GCC? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
important thing: -D does not apply here.
Is it possible to declare macros that appear in every compilation (much like predefined macros) in some dynamic manner (meaning I'm lazy to recompile gcc)? or do I have to recompile my gcc? Should I have to recompile, how do I specify my predefined macros?
You might consider providing some (or improving yours) spec file.
You could patch the gcc/c-family/c-cppbuiltin.c file of the source code of GCC.
You could code then use a GCC plugin defining additional predefined macros.
But I am sure it is a very bad idea; I recommend instead passing explicitly some -D flag to your compiler; your question smells badly as some XY problem. You need to motivate your question.
You could instead organize your PATH variable and add appropriately some gcc shell script adding that -DMACRO option and explicitly invoking e.g. /usr/bin/gcc with it.
On Linux you can
use an alias:
alias gcc="gcc -DMACRO1 -DMACRO2"
Copy old /usr/bin/gcc to /usr/bin/gcc.original. Make your own shell script and name it /usr/bin/gcc, inside which you have
exec /usr/bin/gcc.original -DMACRO1 -DMACRO2 "$#"

When will the safe string functions of C11 be part of glibc? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
The C11 standard Annex K defines a bunch of new safer string functions, all suffixed by _s (e.g. strcpy_s).
Do you know when these new functions will become available in the GNU C library glibc?
So far you have to fall back to a third party library like safec.
Do you know when these new functions will become available in the GNU C library glibc?
When someone contributes an implementation and convinces GLIBC maintainers that these functions are good to have.
Relevant thread from 2007.

Resources