'How to use narrow_cast from gsl

I am trying to run the following code for narrowing errors from Programming: Principles and Practice Using C++ book:

#include<iostream>
#include <gsl/gsl>

using namespace std;

int main()
{
    int x1 = narrow_cast<int> (2.9);
    int x2 = narrow_cast<int> (2.0);
    char c1 = narrow_cast<char>(1066);
    char c2 = narrow_cast<char>(85);

    cout<<x1<<endl;
    cout<<x2<<endl;
    cout<<c1<<endl;
    cout<<c2<<endl;
}

However, I ran into the following error:

fatal error: 'gsl/gsl' file not found

I am sure I have gsl library installed but don't know what I am doing wrong here. I am using MAC OS and VS Code.

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source