I have been implementing a project that uses the external C++ library in Visual Studio 2022.
I have added the Armadillo library in the project properties > C/C++ > General > Additional Include Directories > ...armadillo library location.
I have other additional libraries such as eigen library as well.
I have set the C/C++ > Precompiled Headers > Precompiled Heaader : Not using Precompiled Headers
.
Then I have tried implementing as :Use/Yu or Create/Yc
as well.
Here is my code:
#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier
#include <utility>
#include <iostream>
#include <limits.h>
#include "TxLibrary.h"
// Added C library for the implementation
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// Added C++ library for the implementation
#include <vector>
#include <algorithm>
#include <iomanip>
#include <armadillo>
#include <fstream>
#include <string.h>
void foo(int x, int y) {
int temp = min(x,y);
}
int main() {
foo(2,3);
}
Full error during build including armadillo library:
Error C3861 'min': identifier not found
Warning after removing #include <armadillo>
:
WARNING: undefined conflicting 'min' and/or 'max' macros
Is this because of armadillo library containing min function?
Or am I choosing the wrong setting for the Visual Studio for including the directories?
Use std::min instead of min. Avoid using namespace std
;
Since macro NOMINMAX works, your other header files may indirectly include minwindef.h
.
And add ( )
.
(std::min)(x,y)
should work for you without adding preprocessor: NOMINMAX