0

When I add 'bits/stdc++.h'header file, it shows [Error] reference to 'list' is ambiguous. But when I erase the header and remain all other headers, the code is compiling properly.

#include <bits/stdc++.h>
#include<stdio.h>
#include <iostream>
#include<stdlib.h>
#include <string.h>
#include <sstream>
#define LIST_INIT_SIZE 2
#define NULL_VALUE -99999
#define SUCCESS_VALUE 99999
using namespace std;
int listMaxSize;
int * list;
int length;


void initializeList()
{
    listMaxSize = LIST_INIT_SIZE;
    list = (int*)malloc(sizeof(int)*listMaxSize) ;
    length = 0 ;
}
roktim
  • 81
  • 2
  • 8
  • 3
    "When I add 'bits/stdc++.h' header file" -- that's the problem. You should not add or use the `bits/stdc++.h` header file. Whichever book taught you to do that, you should throw it away and get a proper C++ book. Whichever web site you read this from, you should lose the bookmark. That's not standard C++. – Sam Varshavchik Dec 07 '19 at 04:20
  • 1
    also take a look at: [why is "using namespace std" considered bad practice](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) – kmdreko Dec 07 '19 at 04:21

1 Answers1

3

Thats because the header <bits/stdc++.h> has its own version of list i.e. from the list template <list>. Having two copies or different definitions of the same would result in ambiguity. If its working without the bits header (STL) then simply dont use it.