Author Topic: Include regex.h  (Read 712 times)

Offline Rossati

  • Single posting newcomer
  • *
  • Posts: 4
Include regex.h
« on: September 13, 2019, 10:21:40 am »
Hi
I am using Code::Block 17.2 on windows 10 and I can't include <regex.h>.
I tried to add this search directory C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++ but this is not working.

Thanks

Offline Miguel Gimenez

  • Regular
  • ***
  • Posts: 371
Re: Include regex.h
« Reply #1 on: September 13, 2019, 10:28:09 am »
You must include <regex>, not <regex.h>

Offline Rossati

  • Single posting newcomer
  • *
  • Posts: 4
Re: Include regex.h
« Reply #2 on: September 13, 2019, 12:03:29 pm »
Thanks Miguel
Unfortunately I have tried also
Quote
#include <regex>
, but the result is always
Quote
... fatal error: regex: No such file or directory|
best regards

Offline Miguel Gimenez

  • Regular
  • ***
  • Posts: 371

Offline Rossati

  • Single posting newcomer
  • *
  • Posts: 4
Re: Include regex.h
« Reply #4 on: September 13, 2019, 03:14:10 pm »
I am running Code::Blocks version 17.12 on Windows 10

Build log:
Code: [Select]

-------------- Build file: "no target" in "no project" (compiler: unknown)---------------

mingw32-gcc.exe  -I"C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++\bits" -c C:\Sviluppo\fGenTK\C\re.c -o C:\Sviluppo\fGenTK\C\re.o
mingw32-g++.exe  -o C:\Sviluppo\fGenTK\C\re.exe C:\Sviluppo\fGenTK\C\re.o   
C:\Sviluppo\fGenTK\C\re.c:4:17: fatal error: regex: No such file or directory
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

I have already tried ...
#include <bits/regex.h>
... but none of them worked.

Offline Miguel Gimenez

  • Regular
  • ***
  • Posts: 371
Re: Include regex.h
« Reply #5 on: September 13, 2019, 04:22:55 pm »
TDM 5.1.0 may have no regex, is there a regex file (with no extension) here?

Code: [Select]
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++

If so, that's the path you must add as search directory. If not so, update MinGW to a newer version.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6666
    • My Best Post
Re: Include regex.h
« Reply #6 on: September 13, 2019, 06:10:41 pm »
I suggest either using a Code::Blocks project or finding another IDE.
C::B is designed to use C::B projects; it does a very poor job when not using C::B projects.

http://wiki.codeblocks.org/index.php/Creating_a_new_project

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12086
    • Travis build status
Re: Include regex.h
« Reply #7 on: September 13, 2019, 07:32:50 pm »
@stahta01: Why suggest something that is not helpful? The current problem is not related to the use of projects! Read below for details.

@Rossati: Please rename your file to have .cpp as extension. You're currently using .c which means you're compiling in C mode and not in C++ mode! After that if you have problems with the missing header then you'll need to update your compiler because it might not be available in this version of GCC!

Also next time you could read our FAQ. This problem is specifically addressed there!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Rossati

  • Single posting newcomer
  • *
  • Posts: 4
Re: Include regex.h
« Reply #8 on: September 14, 2019, 09:23:58 am »
Thanks to all

These suggestions have been useful to me:
  • C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\5.1.0\include\c++ contains regex (Miguel)
  • Changed estension to .cpp ( oBFusCATed)
  • I set -std=c+11 (compilation warning)
Unfortunately, an example of using regular expressions that I try to compile, gives me many errors, but this is only my problem.

Best regards