hosseinmoein / DataFrame

C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types and contiguous memory storage
https://hosseinmoein.github.io/DataFrame/
BSD 3-Clause "New" or "Revised" License
2.41k stars 306 forks source link

conflict with include <windows.h> #249

Closed wkingnet closed 1 year ago

wkingnet commented 1 year ago

environment: windows 10 x64, visual studio 2022, install dataframe by vcpkg

I try to learn DataFrame, and I found a conflict with include .

this is my simple test code:

//#include <windows.h>
#define _CRT_SECURE_NO_WARNINGS

#include <DataFrame/DataFrame.h>                   // Main DataFrame header
#include <DataFrame/DataFrameMLVisitors.h>         // Machine-learning algorithms
#include <DataFrame/DataFrameStatsVisitors.h>      // Statistical algorithms
#include <iostream>

using namespace std;
using namespace hmdf;

int main(int, char* []) {

  std::vector<unsigned long>  idx_col2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  std::vector<std::string>    str_col = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" };
  std::vector<std::string>    cool_col =
  { "Azadi", "Hello", " World", "!", "Hype", "cubic spline", "Shawshank", "Silverado", "Arash", "Pardis" };
  std::vector<double>         dbl_col2 = { 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0 };

  StdDataFrame<unsigned long> ul_df2;

  ul_df2.load_data(std::move(idx_col2),
                   std::make_pair("string col", str_col),
                   std::make_pair("Cool Column", cool_col),
                   std::make_pair("numbers", dbl_col2));

  const auto& cool_col_ref = ul_df2.get_column<std::string>("Cool Column");
  const auto& str_col_ref = ul_df2.get_column<std::string>("string col");

  std::cout << cool_col_ref[1] << cool_col_ref[2] << cool_col_ref[3] << std::endl;
  std::cout << "Str Column = ";
  for (auto citer : str_col_ref)
    std::cout << citer << ", ";
  std::cout << std::endl;

  return (0);
}

and it's work fine. successed

But if include , many errors will occur. error

error maybe because calling max function from wrong file: image

wkingnet commented 1 year ago

by google I found a solution:

#define NOMINMAX
#include <windows.h>