can I use c libraries with c++

3 replies [Last post]
kiwon0905
Title: NooBot
Joined: 02/26/2014
Posts:
BotPoints: 5
User offline. Last seen 9 years 14 weeks ago.

I created a c++ project and here is my code

  1. #include <kovan/kovan.h>
  2.  
  3. int main()
  4. {
  5. beep();
  6. }

i get this error
error: (depth.h) INT32_MAX was not declared in this scope

ruler501
ruler501's picture
Title: NooBot
Joined: 01/29/2012
Posts:
BotPoints: 367
User offline. Last seen 8 years 4 weeks ago.

A quick google search suggest that you try adding these lines before your #include

  1. #define __STDC_LIMIT_MACROS
  2. #include <stdint.h>

EDIT: I added c tags so you can actually see the appropriate include.

kiwon0905
Title: NooBot
Joined: 02/26/2014
Posts:
BotPoints: 5
User offline. Last seen 9 years 14 weeks ago.

weird.. that doesn't work.
So i'm just going to manually define it for now

  1. #define INT32_MAX 2147483647

ruler501
ruler501's picture
Title: NooBot
Joined: 01/29/2012
Posts:
BotPoints: 367
User offline. Last seen 8 years 4 weeks ago.

I'm sorry the second line I posted should've been

  1. #include <stdint.h>

though I think it may be replaceable with
  1. #include <cstdint>

EDIT: I didn't realize the forum removed everything enclosed by brackets not in a c code block