-2

strtoull,strtof,strtold,vsnprintf,wcstoll,wcstoull,wcstof, and wcstold are not members of 'std.' The problem is I don't use any of these functions. I didn't even know they existed. they are in file basic_string.h, which I also didn't know I was using. I'm using VS2015 so I assume I am compiling using the VSC++ 14.0 compiler.

I see that there over a dozen similar questions but I can only find two common errors: not using the C++11 flag and not #includeing . I have had the C++11 flag set and #include <algorithm> changes nothing. this question makes me curious,though. I thought the order of #includes didn't matter. I tried system libraries <> first and 3rd party libraries second "" and also vice-versa and observed no difference.

I also tried #include "stdafx.h" as some other answers indicated, but no such file exists.

not sure what to include here because I finally got to the point where the IDE identifies no errors in my code. again, all the issues are in "basic_string.h." here are my includes:

#include <iostrream>
#include <string>
#include <cstring>
#include <sstream>
#include <map>

#include "curl/curl.h"
#include "curl/easy.h"

this may be a continuation of my other question here, which I will update now.

edit 1: I have included <cstdlib>,<cstdio>,and<cwchar> and I see no difference. I'm curious why it's having issues with functions I've never used in files I've never touched.

I totally forgot I ran a repair on VS2015 yesterday and here are the results. I'm not sure if these are optional modules or core issues or what. "Windows Software Development Kit" sounds important but I am not developing for a windows machine(though I am developing on Win7).

edit 2: someone asked for minimal reproducible code. here is the whole file sans comments:

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <map>
#include <cstdio>
#include <cwchar>

int main(int argc, char *argv[])
{
return 0;
}

just realized I don't need all the includes for nothing(because i commented all functional code out) so I will now see which one is causing the issue.

edit 3 : cstring,cstdlib,cstdio, cwchar, and the two curl headers are the only headers that will not cause this issue. I can include all six of them at once without issue. any other #include that was mentioned in the OP or the previous edit will cause the same ...is not a member of 'std'error. However, I don't think I had any of the <c...>included before I started having this issue.iostream,string,sstream,map each (individually even) cause this issue. are we still looking at a complete VS2015 reinstall?

edit 4: As one user suggested, I tried to make a new project but this is what happened. I was really hoping we wouldnt get to this point because I'm not sure how much you all will be able to help. Basically,we have some complicated build setup which I don't understand. The other guy who works here also does not understand the setup. The one person who knows is out on paternity leave. I'm developing on one machine and building/debugging on a server. However, I was poking around the settings and I saw a different diagram that has a second server in the mix and I'm not sure how that plays into it. After that, it is deployed to a different machine. Anyway I selected the same options as the current project but I can't even create a blank one. I'm not sure if this failure is because of this complicated system or because my VS2015 is messed up. Either way I can't fix this as it is so I think I will work on repairing VS2015 (which already had issues once) while monitoring this thread to see if this new project error reveals something important. thanks a lot to all who helped so far

edit 5: I'm taking next week off. I won't be able to give any updates till the 3rd for anybody who still cares. I'm going to repair and then reinstall

pthien
  • 23
  • 1
  • 8
  • 1
    I don't see `` included. From [cppreference](https://en.cppreference.com/w/cpp/string/byte/strtoul): "_std::strtoul, std::strtoull: Defined in header _" Something in your code wants to use those functions. Include that file. Also, why not upgrade to VS2019? – Ted Lyngmo May 23 '19 at 22:47
  • `I thought the order of #includes didn't matter.` - that's incorrect. If foo.h defines something that bar.h references then you do need to include foo.h first, or use a "forward declaration." – Dave S May 23 '19 at 22:48
  • `basic_string.h` is not a standard header – Aykhan Hagverdili May 23 '19 at 22:48
  • Order of include SHOULD NOT matter. I see it as a failure on the part of whoever wrote the header if it does. There may be some legitimate reasons to force an inclusion order rather than making the header itself self-reliant by including or declaring everything it needs, but I've yet to find one. – user4581301 May 23 '19 at 22:53
  • 1
    But then I read the question again and got a reminder of one exception: `#include "stdafx.h"` This sucker MUST go first. [What is “pch.h” and why is it needed to be included as the first header file?](https://stackoverflow.com/questions/54121917/what-is-pch-h-and-why-is-it-needed-to-be-included-as-the-first-header-file) is specifically about pch.h, the modern inheritor to stdafx.h, but explains why better than any of the answers that directly refer to stdafx.h. – user4581301 May 23 '19 at 22:57
  • @TedLyngmo including `````` changes nothing. I'm not sure about VS2019. it's not my call. but I can ask. What is the benefit of upgrading? @DaveS ok thanks – pthien May 23 '19 at 23:00
  • @Ayxan how is this relevant? sorry I cant find a way to say that without sounding rude but I don't understand what makes you say that here. – pthien May 23 '19 at 23:06
  • "_including changes nothing_" - So, it finds the include file, but the functions are still not declared? Your installation seems broken in that case. Upgrading will give you better language support for sure. – Ted Lyngmo May 23 '19 at 23:07
  • Either something is very wrong with your environment or we don't have enough detail. Please present a [MCVE] just to rule out sillinesses. But it's probably an installation problem. – Lightness Races in Orbit May 23 '19 at 23:11
  • pthien I think @Ayxan misread and believes you were trying to directly include it (which would be a bad thing to do). I'm not familiar enough with the layout of Visual Studio's C++ library headers, but in GCC's c++ library basic_string.h is included by string. Quick look through Visual Studio 2015's string header and I don't see anything basic_string.h-ish. – user4581301 May 23 '19 at 23:24
  • @TedLyngmo yes, it finds the file. the functions are still "not a member of 'std'" so I assume that means they are not declared. "your installation seems broken in that case" I assume you mean installation of VS2015.alright, thanks LightnessRacesinOrbit the entire file is now commented out except the headers listed in OP plus the three mentioned in the comments plus a blank main() with return 0; but I will make another edit including this shortly user4581301 yes, I just read some comments in basic_string.h and it says to not include it directly. I do not include it directly – pthien May 23 '19 at 23:41
  • You get "strtoull is not a member of std" from the program you posted that only has standard includes and `int main(...) { return 0; }` ? Really? – M.M May 24 '19 at 00:45
  • Just to confirm, when you are looking through the comments at the top of basic_string.h does it say anything about the Free Software Foundation or GNU Licenses? If it does something's gone off into left field and you're looking at a GCC header, not a Visual Studio header. How that would have happened, ed if I know. – user4581301 May 24 '19 at 01:09
  • Just searched a computer with Visual Studio 2010 Pro, Visual Studio 2015 pro update 3, and more GCC versions than I thought I had. All of the basic_string.hs found are in the GCC folders. I'm not quite sitting in the broken Visual Studio camp because it could just be a broken project. What happens if you make yourself a brand-new project and paste in your minimal example? – user4581301 May 24 '19 at 01:28
  • @M.M yes the headers in edit 2 cause this error. more information about headers in edit 3. user4581301 yes, I see the statements about Free Software Foundation and GNU ISO C++ Library. basic_string.h is located in c++/4.9.2/bits. I tried to make a new project but I was unable to because "toolchain test failed...Failed to link a test program." I can't post a picture here so I'll have to make a new edit on the OP. – pthien May 24 '19 at 16:47
  • Have you ever been able to compile C++ code with this Visual Studio installation? Thinking back to when I installed Visual Studio 2015, the default was to NOT install C++ support. Somewhere in the options dialogues in the installer was an option to install C++. – user4581301 May 24 '19 at 16:59
  • @user4581301 yes I have been working on this project for about a month. it hasn't been without issues, but it has compiled and run many times – pthien May 24 '19 at 17:11
  • @user4581301 ah I see what you are talking about. Visual C++-->Common Tools for Visual C++ 2015, Microsoft Foundation Classes for C++, and Windows XP Support for C++. all four are checked – pthien May 24 '19 at 18:34
  • It would be better to edit the question to show the minimal example plus a description of the problem, and remove all the irrelevant guff. People can view the edit history on this site, you don't need to record a diary – M.M May 24 '19 at 22:13

3 Answers3

1

Those functions are in the namespace std if you include the correct standard headers, which are <cstdlib>, <cstdio> and <cwchar>. "basic_string.h" is not a standard header; it is probably some implementation specific header. "stdafx.h" is what Visual Studio uses for precompiled headers (it's not in the standard either) and the order in which you include headers can matter although it usually shouldn't.

Aykhan Hagverdili
  • 28,141
  • 6
  • 41
  • 93
  • I included the three standard headers that you mentioned and observed no change. what does "basic_string.h" not being a standard header have to do with anything? you are the second person to mention that and I don't understand the significance. – pthien May 23 '19 at 23:10
  • _"The problem is I don't use any of these functions."_ – Lightness Races in Orbit May 23 '19 at 23:10
0

I see that there over a dozen similar questions but I can only find... not #includeing

That appears to be the problem.

In order to use standard functions, the header which declares those functions must be included. The listed functions cannot be used because the corresponding headers haven't been included.

For example, strtoull is declared in <cstdlib>, which has't been included according to your quoted list of includes.

The problem is I don't use any of these functions. I didn't even know they existed. they are in file basic_string.h

If the error indicates that basic_string.h uses those functions, and that's the list of headers that basic_string.h includes, then basic_string.h is buggy.

I'm curious why it's having issues with functions I've never used in files I've never touched.

You either use basic_string.h, or you use some header that in trurn uses basic_string.h. The error message should tell you how the inclusion takes place.

I have ... #include <algorithm>

Including <algorithm> lets you use the declarations from that header. It doesn't let you use declarations from other headers.


I also tried #include "stdafx.h" as some other answers indicated, but no such file exists.

If your project is configured to use pre-compiled "stdafx.h", then you must include it. If it is not configured to use it, then you must not include it. Pre-compiled headers must be included before anything else in your file.

eerorika
  • 232,697
  • 12
  • 197
  • 326
  • _"The problem is I don't use any of these functions."_ – Lightness Races in Orbit May 23 '19 at 23:10
  • @LightnessRacesinOrbit Hmm. I'll need to re-word. – eerorika May 23 '19 at 23:11
  • alright thanks. I tried to```#include "stdafx.h"```, but it could not find the file. so it must not be configured to use it. – pthien May 23 '19 at 23:12
  • "If the error indicates that basic_string.h uses those functions, and that's the list of headers that basic_string.h includes, then basic_string.h is buggy." basic_string.h does use at least some of those functions. it does not include those three headers but it does include ```ext/atomicity.h```,```debug/debug.h```,```initializer_list```,```ext/string_conversions.h```,and```bits/functional_hash.h``` "You either use basic_string.h, or you use some header that in trurn uses basic_string.h. The error message should tell you how the inclusion takes place." it is the latter – pthien May 23 '19 at 23:34
  • @pthien `it is the latter` Yes, but the message should tell you exactly which of the headers that *you* include ends up including the problem header. – eerorika May 23 '19 at 23:36
  • not that I can see. there's the message, project name, file name, and line number – pthien May 24 '19 at 17:13
0

it was a problem with my Include directories in VisualGDB Properties-->Makefile settings. I was adding a new directory for each library I got. I reinstalled VS2015, but that did nothing because the culprit was a project option. I copied the default* include directories and that was it.

*someone on my team provided me with a list of the default include directories

pthien
  • 23
  • 1
  • 8