Thread: error C3861

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    21

    error C3861

    Hi,

    I am getting the error :

    c:\program files\labpacks\visual c++\include\vclobjects.h(99) : error C3861: 'wcstombs_s': identifier not found

    c:\program files\labpacks\visual c++\include\vclobjects.h(379) : error C3861: 'mbstowcs_s': identifier not found

    Any ideas pls.

    Thanks,

    Emma.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Try adding a "#include <stdlib.h> before #include'ing the vcl.h.

    wcstombs_s and mbstowcs_s are both function that Microsoft declares in <stdlib.h>.

    I'd advise not using those functions at all, if you care about portability of your code, but that's a moot point as you're using the VCL, which is also non-portable.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    21
    Quote Originally Posted by grumpy View Post
    Try adding a "#include <stdlib.h> before #include'ing the vcl.h.
    Thanks for the reply. The project does not use vcl.h. (it was made by someone else; i have to extend it, trying to compile it first) . Other than that, I am jotting down the list of #includes below:


    #include <afxwin.h>
    #include <afxext.h>
    #include <afxcmn.h>
    #include "resource.h"
    #include <CSLScope.h>
    #include "stdafx.h"
    #include <fstream.h>
    #include <math.h>
    #include <string.h>

    Is there a dependency of the error on any of these headers. BTW can it be a compiler specific error; I am on Visual Studio 2008 SP1.

    Thanks,
    Emma Good.

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Sorry - I typed too fast, and meant before the vclobjects.h. The fact you are getting those error messages means one of those header files you listed (or a header that they #include .....) is #include'ing vclobjects.h. However, the missing symbols will be within <stdlib.h> if you are using Microsoft's compiler. Try placing #include <stdlib.h> before the first of those #include's you listed.

    Those particular missing symbols are specific to Microsoft's compilers and the association libraries (although some other vendors may support them in the interests of compatibility).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  5. #5
    Registered User
    Join Date
    May 2012
    Posts
    21
    Quote Originally Posted by grumpy View Post
    Try placing #include <stdlib.h> before the first of those #include's you listed.

    Those particular missing symbols are specific to Microsoft's compilers and the association libraries (although some other vendors may support them in the interests of compatibility).
    Hi Grumpy,

    The project has 5 source files and 5 corresponding header files. I tried by inserting '#include <stdlib.h>' in the first lines of all the 10 files ! Didnt work that way.

    Emma Good.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    wcstombs_s, _wcstombs_s_l
    The function is supposedly declared in stdlib.h

    However, it may have some conditional compilation guards, which prevent those declarations being visible in the project you're trying to build.

    Eg.
    Code:
    #ifdef FOOBAR
    errno_t wcstombs_s(
       size_t *pReturnValue,
       char *mbstr,
       size_t sizeInBytes,
       const wchar_t *wcstr,
       size_t count 
    );
    #endif
    Now, if FOOBAR isn't set for your project, or some other header file before stdlib.h has #undef FOOBAR, then you won't see the declaration of wcstombs_s
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    May 2012
    Posts
    21
    Hi Salem,

    Nice to hear back from you. If I understood you point correctly, I can stdlib.h in the first line of the code to get over the issue. Pls. let me know if I am right. Actually I tried that but no joy.

    Thanks,
    Emma

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    To be honest, I think you should start with a new console project which has just stdlib.h and a main() calling wcstombs_s, just to prove to yourself that there isn't anything wrong with your environment.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User
    Join Date
    May 2012
    Posts
    21
    Quote Originally Posted by Salem View Post
    To be honest, I think you should start with a new console project which has just stdlib.h and a main() calling wcstombs_s, just to prove to yourself that there isn't anything wrong with your environment.

    Hi Salem,

    I tried as per you advice. I uninstalled Visual Studio 2008 and installed it back. Then opened the project as fresh (did not Ok when the prompt came up to open the existing project). when I started compiling it; this time it could not find the header file 'afxdtctl.h'. I then searched the entire computer for the path to this header file. It did not show up in the search !

    BTW I had opened up another query just to get a second opinion from the people.

    Thanks,
    Emma Good

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Salem's advice is for you to start with a new console project, i.e., an entirely new project, from scratch. This is just to test that you can call wcstombs_s with such a fresh project.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #11
    Registered User
    Join Date
    May 2012
    Posts
    21
    Hi Salem and laserlight,

    I was able to compile the code. I was basically missing a header folder 'altmfc' at my end. Anyways, thanks for all the help.

    Emma Good.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 07-24-2011, 09:38 PM
  2. error C3861: 'Create': identifier not found
    By mark103 in forum C++ Programming
    Replies: 1
    Last Post: 04-23-2011, 10:01 AM
  3. Error C3861: 'menu': identifier not found
    By blacknail in forum C++ Programming
    Replies: 6
    Last Post: 09-11-2009, 09:34 AM
  4. error C3861,
    By jordanguyoflove in forum C Programming
    Replies: 3
    Last Post: 11-26-2008, 07:39 AM
  5. Error messages C3861 and C2084 in user-defined headers
    By JackR in forum C++ Programming
    Replies: 2
    Last Post: 09-11-2006, 12:42 PM