3

I'm trying to run a unix compiler-project written in c with MS Visual-Studio 2013 and I can't get rid of the following error:

error LNK2019: unresolved external symbol "_snprintf" referenced in 
    function "PUBLIC void SyntaxError( int Expected, TOKEN CurrentToken )"

If I get it right it is a problem where VisualStudio can't find the body/declaration from the snprintf() function, which should be defined in stdio.h.

The project works fine with cygwin. I had to add _CRT_SECURE_NO_WARNINGS to preprocessor settings to get this far, but i don't think that has a influence.

Here is the named function:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "line.h"
#include "strtab.h"
#include "scanner.h"

[..code..]


PUBLIC void   SyntaxError( int Expected, TOKEN CurrentToken )
{
    char s[M_LINE_WIDTH+2];

    snprintf( s, sizeof(s), "Syntax: Expected %s, got %s\n", Tokens[Expected], Tokens[CurrentToken.code] );
    Error( s, CurrentToken.pos );
}

If you can help me or there is anything else you need to know please tell me. It's my 3rd day now and I am running out of ideas ;).

So far... Tobias

Iharob Al Asimi
  • 52,653
  • 6
  • 59
  • 97
ducii
  • 33
  • 3

1 Answers1

5

The name of this function with the MSVC compiler is _snprintf() with an underscore.

Iharob Al Asimi
  • 52,653
  • 6
  • 59
  • 97
  • Oh man my bad. There is a secound function i didn't remember. It worked. Thanks a million!!! You saved my day! – ducii Apr 19 '15 at 16:50