How to do it...

We are going to create a simple application that creates three time points and compares them to each other.

  1. In your  ~/test working directory, create a subdirectory called chrono.
  2. Use your favorite text editor to create a chrono.cpp file in the chrono subdirectory.
  3. Put the following code snippet into the file:
#include <iostream>
#include <chrono>

using namespace std::chrono_literals;

int main() {
auto a = std::chrono::system_clock::now();
auto b = a + 1s;
auto c = a + 200ms;

std::cout << "a < b ? " << (a < b ? "yes" : "no") << std::endl;
std::cout << "a < c ? " << (a < c ? "yes" : "no") << std::endl;
std::cout << "b < c ? " << (b < c ? "yes" : "no") << std::endl;

return 0;
}
  1. Create a CMakeLists.txt file containing build rules for our program:
cmake_minimum_required(VERSION 3.5.1)
project(chrono)
add_executable(chrono chrono.cpp)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

SET(CMAKE_CXX_FLAGS "--std=c++14")
set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabi-g++)

You can now build and run the application. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.111.24