This question already has answers here:
Regex.h for windows
(1 answer)
C: Regex library with MinGW
(2 answers)
Closed 4 months ago.
I'm trying to use regular expression for a project in C but it seems like it's not working or I'm maybe missing something.
When I try to #include <regex.h> it says Cannot open source file 'regex.h'.
When I try to #include <regex> it breaks my size_t data type and makes all my function calls not allowed in a constant expressions.
What do I need to make it work using Visual Studio as an environment, maybe there is an easier way to use regular expressions in C
Related
This question already has answers here:
Nested function in C
(9 answers)
Closed 3 years ago.
I read that nested function don't exist in C.
I then successfully executed the following piece of code using the cc command on my linux machine.
#include <stdio.h>
#include <string.h>
int main(){
float dummy(){
printf("hello\n");
}
dummy();
return 0;
}
I got the the output hello.
How does that play out?
Does my compiler support nested functions?
GNU C supports nested functions as an extension. Your cc binary on your Linux machine is almost certainly a symlink to gcc.
Nested functions don't exist in standard C. However, it might be supported as an extension in certain compilers like GNU.
This question already has answers here:
Disabling Warnings generated via _CRT_SECURE_NO_DEPRECATE
(10 answers)
Closed 5 years ago.
I'm currently trying to get some C code that I originally wrote for linux (gcc) to build on a win32 box.
The MSVC compiler is giving me warnings for all my printf and scanf usage suggesting I should use printf_s and scanf_s instead as a more secure alternative.
Its never nice to ignore 100's of compiler warnings, but should I in this instance?
Is there a simple workaround to fix this? Perhaps encapsulate those functions in a platform specific preprocessor directive?
You can suppress these warning by defining _CRT_SECURE_NO_DEPRECATE before the #include statements. But you should consider to use the new, secure functions.
This question already has answers here:
How to embed version information into shared library and binary?
(4 answers)
Closed 6 years ago.
I have situation as below:
#define CONSTANT 123
foo()
{
...
}
Using the above code, after creating the library lets say test.so, how can get to know the CONSTANT macro value from the library? Is there any way?
You can define the constant in a header file and supply that header with the library.
There are ways to do that:
Define the constant in a header file to the library and distribute it with the library
Make the library some form of open source
Write a dedicated get_constant function that returns the value
Its worth noting that Macros are always sheer text replacement. So after compile time you won't even know they were there.
This question already has answers here:
How to know (in GCC) when given macro/preprocessor symbol gets declared?
(6 answers)
Closed 7 years ago.
How can I find the include file, from which a certain preprocessor definition was found by GCC?
In a successfully compiling C file, I have a strange macro which I do not understand. For a start, I want to see the file where it comes from. The include hierarchy is very deep; is there an easy way to find the source of the macro?
A wider question has been asked, but the answers tell how to find the definition itself, not its source file.
redefine it before including anything else, the compiler will complain about a redefinition when it encounters it in your header hierachy:
#define MY_PROBLEMATIC_MACRO
#include <the_header.h>
/* code */
This question already has answers here:
Where are the functions in the C standard library defined?
(5 answers)
Closed 7 years ago.
Functions like printf() , scanf() , memset() , puts() etc have their declaration in header files but is there any mechanism to see the definition of these function..?
This might not be a new question but i could not find the appropriate solution for this.
Find your compilers include path (e.g. GCC solution)
Search for the header you are interested in (e.g. printf should be in stdio.h or more likely another header included by stdio.h)
Correctly configured, some IDEs will help you with that, e.g. Eclipse
The method has its limits though, because at some point the include files will get less and less Standard-C, but more and more compiler dependent. The C-standard does not prescribe the contents of standard headers. It merely states that if you write #include <stdio.h>, you can use printf(). That does not necessarily mean that stdio.h has some form you might expect.