9
extern "C" 
{
#endif
#include <stdint.h>
#include <limits.h>
#include "attributes.h"
}
#endif

I added extern "C" { } Then i got the C2059 string error So i tried to use #endif, now i have another 4 errors.

Error   1   error C2059: syntax error : 'string'    d:\c-sharp\c++ 
compiling\consoleapplication7\consoleapplication7\libavutil\rational.h 31 1
ConsoleApplication7

How can i fix this string error ?

Suvarna Pattayil
  • 5,136
  • 5
  • 32
  • 59
Ben Kochavi
  • 293
  • 1
  • 4
  • 15
  • Why do you do this in the first place? – bash.d Apr 23 '13 at 12:37
  • 5
    `#ifdef X ... #endif` is normally how it goes, not `#endif` twice. Unless you haven't posted all your code? – Tony The Lion Apr 23 '13 at 12:37
  • 4
    The `extern "C" {` declaration and closing `}` would normally be enclosed by `#ifdef __cplusplus`, `#endif`. If you don't do this, you'd have to ensure your header wasn't included from a C source file – simonc Apr 23 '13 at 12:38
  • 2
    Please post the _original_ code, as complete as possible (also please see http://sscce.org/ for help). Then please post the complete and unedited error messages, while pointing out what line in the source they are about. – Some programmer dude Apr 23 '13 at 12:39
  • Joachim the original post the problem of my code is here: http://stackoverflow.com/questions/16155783/how-to-resolve-link-errors-due-to-addition-of-lib-files-to-a-c-project-in-vis i have 9 erorrs of this link. I tried to google and tried any solution copied all bin files and dll files to the debug and to the solution directories nothing helped. So i tried this extern "C" but it didn't help either. Can't figure out why this errors happen. – Ben Kochavi Apr 23 '13 at 12:47
  • I can upload my complete project it's very small to my skydrive maybe someone can take a look on it ? I'm trying to use C language function part of ffmpeg in my c++ project. So i tried to use all dll's i have downloaded and bin files and i set all directories in the project properties also in the linker properties. But nothing helped so far. – Ben Kochavi Apr 23 '13 at 12:48
  • This is the ffmpeg code i tried to use in my c++ project: http://www.ffmpeg.org/doxygen/trunk/encoding_8c-source.html the function from line 195 only this function. – Ben Kochavi Apr 23 '13 at 12:49
  • The goal for now is just to put the c ffmpeg function in my c++ project and to compile it see that it will compile without errors see that the function is doing and working as it should be. That's what i need to do now. – Ben Kochavi Apr 23 '13 at 12:50
  • Here is a link to my project: https://skydrive.live.com/redir?resid=EB1C71C44C3976D5!194&authkey=!ANAmiEavuqaqKDk maybe someone can see it and find out why i'm getting those link errors. – Ben Kochavi Apr 23 '13 at 13:10

1 Answers1

26

At a guess, are you including this code from a C source file?

extern "C" { guards are only required (or understood) by C++. You can omit them from a C file, should include them in a C++ file and should guard them with a __cplusplus ifdef in a header file.

#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <limits.h>
#include "attributes.h"
#ifdef __cplusplus
}
#endif
simonc
  • 41,632
  • 12
  • 85
  • 103