Error c2220 the following warning is treated as an error

I am getting the following error while building a project. Even though I am setting the property "treat warning as errors" to "NO" I am getting this one: error C2220: warning treated as error - no

I am getting the following error while building a project. Even though I am setting the
property «treat warning as errors» to «NO» I am getting this one:

error C2220: warning treated as error - no object file is created.

Can any one Help me Resolving This One? Thanks in Advance.

sam hocevar's user avatar

sam hocevar

11.8k5 gold badges47 silver badges67 bronze badges

asked Jun 1, 2009 at 7:35

Cute's user avatar

1

The documentation for C2220 suggests compiling at a lower warning level. It also shows that the warning treated as error option is implemented as a compiler flag: /WX. So you could search your .vcproj file for that text and manually remove it from the file.

answered Jun 1, 2009 at 15:41

sean e's user avatar

sean esean e

11.7k3 gold badges43 silver badges56 bronze badges

Probably you forgot to add an header. Just where you get the first warning and see in what header file is defined.

Regards

answered Jun 1, 2009 at 7:56

Sacx's user avatar

SacxSacx

6,2364 gold badges21 silver badges29 bronze badges

I got «error C2220: warning treated as error — no object file is created.» in below code.
Once I changed datatype of total to int , the error was resolved.

int colNum=0;
unsigned int total=123;
for (colNum=0;colNum<total;colNum++) {

answered Jul 14, 2014 at 20:46

sparco's user avatar

sparcosparco

851 silver badge7 bronze badges

1

#pragma warning(disable : 4146)

Set this at the file level instead of changing the project setting.

answered Sep 3, 2014 at 11:37

Akaanthan Ccoder's user avatar

Akaanthan CcoderAkaanthan Ccoder

2,1395 gold badges21 silver badges37 bronze badges

  • Remove From My Forums

 locked

error C2220: warning treated as error — no ‘object’ file generated Driver

  • Question

  • Hi,

    I have been trying to develop a basic Driver for Windows 7 x86, I have followed the MSDN tutorial to develop a basic Driver. The code followed in MSDN tutorial works although, I changed it a little bit: 

    #include <ntddk.h>
    
    NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
    {
        DbgPrint("Hello, World");
    
        return STATUS_SUCCESS;
    }

    I also researched into to this and removed — /WX (Treat Warnings as Errors) to prevent warnings to be treated as error. 

    With this changed I am still getting the same errors:

    error C2220: warning treated as error - no 'object' file generated	C:KmdfSmallKmdfSmallDriver.c

    This should have been wipedremoved by the change in setting. Or is this supposed to happen? I only ever truly developed Drivers on Windows XP, so I am seeing if this works, although logically it should work.

    Anyways, does anyone have a solution to this problem? Or is this syntactical Error?

    Any help will be appreciated,

    Rohan Vijjhalwar

Answers

  • Assuming this is the Win8 WDK, I suspect you removed the -WX from the wrong configuration.  The warnings are probably because you are not referencing the arguments of DriverEntry.  It may be easier to just use the UNREFERENCED_PARAMETER macro to
    take care of the problem.

    Using /W4 and /WX are wise things to do in all cases.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    • Marked as answer by

      Sunday, October 20, 2013 9:53 PM

  • I suspect the «error» is that you have unreferenced parameters. If you lower your warning level (default is 4), or use the UNREFERENCED_PARAMETER macro on your two parameters, you will solve the problem. Also, instead of NTDDK.H, you should probably
    use WDM.H because it is more comprehensive — although it won’t matter for such a simple example.

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting.

    • Marked as answer by
      RRohanR
      Sunday, October 20, 2013 9:52 PM

Содержание

  1. MSVC 2017 error C2220: warning treated as error — no ‘object’ file generated #1373
  2. Comments
  3. Scenario 1 (gmock)
  4. Scenario 2 (gtest & gtestmain)
  5. error C2220 #76
  6. Comments
  7. error C2220 #76
  8. Comments
  9. Visual Studio 2015 Warnings after upgrade #222
  10. Comments
  11. Error c2220 warning treated as error no object file generated
  12. Answered by:
  13. Question
  14. Answers
  15. All replies

MSVC 2017 error C2220: warning treated as error — no ‘object’ file generated #1373

git tag: release-1.8.0
configure: cmake 3.10.0
generator: Visual studio 15 2017 Win64

Scenario 1 (gmock)

  • BUILD_GMOCK:BOOL=ON
  • BUILD_GTEST:BOOL=ON

Scenario 2 (gtest & gtestmain)

  • BUILD_GMOCK:BOOL=OFF
  • BUILD_GTEST:BOOL=ON

The text was updated successfully, but these errors were encountered:

It would probably be good to disable -Werror or /WX for users of this library – compilers can change, new warnings can be generated. It should still be enabled for your own tests, say on CI or so.

This appears to have been fixed in Visual Studio 15.5.5. 718fd88 works well for me.

Is there any simple way (like cmake argument) to skip this error when building release-1.8.0 tag?

Actually warning itself (not the error posted above) gives a good clue.
Warning:

googletestincludegtestgtest-printers.h(639):
warning C4996: ‘std::tr1’: warning STL4002: The non-Standard std::tr1 namespace and TR1-only machinery are deprecated and will be REMOVED. You can define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to acknowledge that you have received this warning. [buildgooglemockgmock.vcxproj]

So I ran cmake like this and it helped:
cmake . -DCMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING

Although you can get a different warning, then this won’t work obviously.
In general to switch off /WX completely you can call like this: cmake . «-DCMAKE_CXX_FLAGS=/w»

Источник

error C2220 #76

Hello,I follow the steps but encountered an error c2220 while running build.cmd.
and I try to disable treat warnings as errors but it`s not work.
Is that because my system language is Chinese?

The text was updated successfully, but these errors were encountered:

Looks like the file contains a character that cannot be returned in your code page, see https://msdn.microsoft.com/en-us/library/ms173715.aspx. Can you try saving that for (half.h) as utf8 ?

I have verified that this file from the Eigen library does indeed contain characters that should have been encoded at UTF-8. This is how I did it. When I use Visual Studio to save the file with ansii encoding like this:

then you will see Visual Studio correctly report the error:

But if you save it with this encoding then everything is fine, and this should work on your machine.

But the characters in the file that are causing this problem are probably in every single Eigen file because it is part of the copyright header. Specifically it is the special curly quotes used in this part of the header:

If you replace the curly quotation characters with simple double quotes «» then that should also fix it.

Technically this is a bug in the Eigen library, they should have UTF-8 encoded all their files. So if you have a tool that can utf-8 encode all the Eigen files then I would use that just in case there are any other special characters used anywhere. Trick is that tool probably needs to load them as Western European Codepage 28591, and not the default code page of the system. It is your default code page that does not contain those special characters.

Источник

error C2220 #76

Hello,I follow the steps but encountered an error c2220 while running build.cmd.
and I try to disable treat warnings as errors but it`s not work.
Is that because my system language is Chinese?

The text was updated successfully, but these errors were encountered:

Looks like the file contains a character that cannot be returned in your code page, see https://msdn.microsoft.com/en-us/library/ms173715.aspx. Can you try saving that for (half.h) as utf8 ?

I have verified that this file from the Eigen library does indeed contain characters that should have been encoded at UTF-8. This is how I did it. When I use Visual Studio to save the file with ansii encoding like this:

then you will see Visual Studio correctly report the error:

But if you save it with this encoding then everything is fine, and this should work on your machine.

But the characters in the file that are causing this problem are probably in every single Eigen file because it is part of the copyright header. Specifically it is the special curly quotes used in this part of the header:

If you replace the curly quotation characters with simple double quotes «» then that should also fix it.

Technically this is a bug in the Eigen library, they should have UTF-8 encoded all their files. So if you have a tool that can utf-8 encode all the Eigen files then I would use that just in case there are any other special characters used anywhere. Trick is that tool probably needs to load them as Western European Codepage 28591, and not the default code page of the system. It is your default code page that does not contain those special characters.

Источник

Visual Studio 2015 Warnings after upgrade #222

When opening the solution for the first time, and building in Release/Win32, I got the following:

1>C:Program Files (x86)Windows Kits8.1Includeumdbghelp.h(1544): error C2220: warning treated as error — no ‘object’ file generated
1>C:Program Files (x86)Windows Kits8.1Includeumdbghelp.h(1544): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared
1>C:Program Files (x86)Windows Kits8.1Includeumdbghelp.h(3190): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared
2>C:Program Files (x86)Windows Kits8.1Includeumdbghelp.h(1544): error C2220: warning treated as error — no ‘object’ file generated (compiling source file minidump_generator.cc)
2>C:Program Files (x86)Windows Kits8.1Includeumdbghelp.h(1544): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared (compiling source file minidump_generator.cc)
2>C:Program Files (x86)Windows Kits8.1Includeumdbghelp.h(3190): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared (compiling source file minidump_generator.cc)
2>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(1544): error C2220: warning treated as error — no ‘object’ file generated (compiling source file client_info.cc)
2>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(1544): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared (compiling source file client_info.cc)
2>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(3190): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared (compiling source file client_info.cc)
3>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(1544): error C2220: warning treated as error — no ‘object’ file generated
3>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(1544): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared
3>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(3190): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared
2>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(1544): error C2220: warning treated as error — no ‘object’ file generated (compiling source file crash_generation_server.cc)
2>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(1544): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared (compiling source file crash_generation_server.cc)
2>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(3190): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared (compiling source file crash_generation_server.cc)
4>—— Build started: Project: renderdoc, Configuration: Release Win32 ——
4>LINK : fatal error LNK1181: cannot open input file ‘C:srcrenderdocrenderdoc3rdpartybreakpadWin32Releasecrash_generation_client.lib’
5>—— Build started: Project: renderdoccmd, Configuration: Release Win32 ——
5> renderdoccmd_win32.cpp
5>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(1544): error C2220: warning treated as error — no ‘object’ file generated
5>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(1544): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared
5>C:Program Files (x86)Windows Kits8.1IncludeumDbgHelp.h(3190): warning C4091: ‘typedef ‘: ignored on left of » when no variable is declared
========== Build: 0 succeeded, 5 failed, 11 up-to-date, 0 skipped ==========

It seems to be all in a Windows header, but obviously doesn’t build out of the box on this system.

The text was updated successfully, but these errors were encountered:

Does it also do this if you move the solution to the 10.0.10240.x or 10.0.10586.0 SDKs?
I’ve always handpatched away the warnings in dbghelp.h and suchlike in previous builds of my software, as they to my knowledge are not circumventable.

Created pull request 223: #223

This is kind of ridiculous that microsoft haven’t fixed this. I remember encountering this before win10 came out in one of their pre-release SDKs and I assumed it’d be fixed by release.

RE: The pull request I’d rather not make that change everywhere, especially if it’s needed in breakpad — I avoid making non trivial in-repo changes to external libraries so in that case it’d need to have a separate fork set up, apply the changes, and sync to my fork.

I think a better solution is as @zao suggested, just hand-patch the warnings in dbghelp.h and include it in renderdoc’s source tree and #include that. It’s a bit more awkward to find a location since it’s needed in several different places. I think the best place is to put it in renderdoc/3rdparty/dbghelp/dbghelp.h and instead of doing the #pragma push/pop dance you’d do #include dbghelp/dbghelp.h — I think all projects should have renderdoc/3rdparty in their include search path. Maybe pdblocate won’t, in which case just add it.

Not a particularly pleasant solution, but that’s how it works cleaning up someone else’s mess :(.

I’m a bit concerned that including DbgHelp.h from a particular Windows SDK version might cause problems with other Windows SDK versions. do you have any testing to cover this? I don’t want to break something down the line.

Alternately we could simply suppress this warning in the breakpad project and use the push/pop in the renderdoc-owned code. (Sorry, I hadn’t noticed that you pull in some third party code)

Yeh I can understand that. It should be fine though as I already ship a bunch of sdk headers for d3d to remove dependency on the sdk. The dbghelp api is stable so there shouldn’t be any issue.

Why not simply have a rd_dbghelp.h which solely consist of the #pragma to disable warnings and includes the MSFT ? That way you don’t have a local copy, and you can protect the pragmas with a version check, and warnings are fixed as well.

Источник

Error c2220 warning treated as error no object file generated

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

vsprintf(buf, s, va);

The Visual Studio 2005 Express Edition compiler gives the following error:

.strgen.c(87) : error C2220: warning treated as error — no ‘object’ file generated

.strgen.c(87) : warning C4996: ‘vsprintf’ was declared deprecated

What do I do? What do I replace it with? Please help. Thank you.

Answers

That is because vssprintf_s takes a different set of parameters:

int vsprintf_s(
char * buffer ,
size_t sizeInBytes ,
const char * format ,
va_list argptr
);

// crt_vsprintf_s.c
// This program uses vsprintf_s to write to a buffer.
// The size of the buffer is determined by _vscprintf.
#include
#include
void test( char * format, . )
<
va_list args;
int len;
char * buffer;
va_start( args, format );
len = _vscprintf( format, args )
// _vscprintf doesn’t count + 1;
// terminating ‘’
buffer = malloc( len * sizeof(char) );
vsprintf_s( buffer, len, format, args );
printf( buffer );
free( buffer );
>

int main( void )
<
test( «%d %c %dn», 123, ‘

If you look up in the documentation it states:

These functions are deprecated because more secure versions are available; see vsprintf_s, vsprintf_s_l, vswprintf_s, _vswprintf_s.

So I would probably start with those. 😉

vsprintf_s(buf, s, va);

and still it sprouts some errors. I cannot find documentation for them.

Источник

Comments

@agirault

@agirault
agirault

changed the title
MSVC 2017 gmock error C2220: warning treated as error — no ‘object’ file generated

MSVC 2017 error C2220: warning treated as error — no ‘object’ file generated

Jan 2, 2018

heinrich5991

added a commit
to heinrich5991/ddnet
that referenced
this issue

Jan 5, 2018

@heinrich5991

Warnings for GTest broke the build because GTest turns warnings into
errors, which is undesirable if GTest is just used as a dependency.

See also google/googletest#1373.

bors bot

added a commit
to ddnet/ddnet
that referenced
this issue

Jan 10, 2018

@bors

978: Disable warnings for GTest r=Learath2 a=heinrich5991

Warnings for GTest broke the build because GTest turns warnings into
errors, which is undesirable if GTest is just used as a dependency.

See also google/googletest#1373.

This was referenced

May 4, 2018

@hobu
hobu

mentioned this issue

Jun 10, 2019

facebook-github-bot

pushed a commit
to facebook/wangle
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebook/fb303
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebookarchive/fbmeshd
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebookincubator/fizz
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to rsocket/rsocket-cpp
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebook/watchman
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebook/fboss
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebook/proxygen
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebookincubator/below
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebookincubator/mvfst
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebookarchive/bistro
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebookarchive/fbzmq
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebook/folly
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebook/fbthrift
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebook/sapling
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebookexperimental/rust-shed
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebook/openr
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebookincubator/katran
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebookarchive/LogDevice
that referenced
this issue

Oct 1, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

facebook-github-bot

pushed a commit
to facebookincubator/reindeer
that referenced
this issue

Oct 2, 2020

@lnicco

@facebook-github-bot

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

lukaspiatkowski

pushed a commit
to lukaspiatkowski/rust-shed
that referenced
this issue

Oct 21, 2020

@lnicco

@lukaspiatkowski

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

dotconnor

pushed a commit
to indaq-cloud/folly
that referenced
this issue

Mar 19, 2021

@lnicco

@dotconnor

Summary: hitting google/googletest#1373

Reviewed By: mjoras

Differential Revision: D23785392

fbshipit-source-id: 114849ed966fb196bb8392bd71ee3c2972834279

У меня есть ниже класс:

class Cdata12Mnt
{
public:
char IOBname[ID1_IOB_PIOTSUP-ID1_IOB_TOP][BOADNAM_MAX + 4];
char ExIOBname[ID1_MAX_INF-ID1_EXIOB_U1TOP][BOADNAM_MAX + 4];
char cflpath[256];
char basetext[256];
UINT database[ID1_MAX_INF];
int State;

public:
char SelectPath[256];

public:
int GetIOBName(int slt,char *Name);
Cdata12Mnt(char *SelectPath);
virtual ~Cdata12Mnt();
int     GetValue(int id);
int     GetState() { return State; }
};

И у меня есть функция как ниже:

Cdata12Mnt::Cdata12Mnt(char *SelectPath)
{
SCTReg  reg;
char    buf[256], *cpnt, *npnt, *bpnt1, *bpnt2;
char    *startcode[] = {"CNTL_CODE ","SEGMENT "};
char    *stopcode    = {"END_CNTL_CODE "};
FILE    *fp;
int     ii, infl;

State = 0;

for (ii = 0; ii < (ID1_IOB_PIOTSUP - ID1_IOB_TOP); ii++) {
strcpy(IOBname[ii], "");
}

for (ii = 0; ii < (ID1_MAX_INF-ID1_EXIOB_U1TOP); ii++) {
**strcpy(ExIOBname[ii], "");**
}

sprintf(cflpath, "%s\%s", SelectPath, CDATAFL);

if ((fp = fopen(cflpath,"r"))!=NULL) {
for (ii = 0, infl = 0; fgets(buf, 256, fp) != NULL;) {
if (infl == 0 && strncmp(buf, startcode[0], strlen(startcode[0])) == 0) {
if ((cpnt = strchr(&buf[strlen(startcode[0])],*startcode[1])) != NULL) {
if (strncmp(cpnt,startcode[1], strlen(startcode[1])) == 0) {
infl = 1;
continue;
}
}
}

if (infl == 0) {
continue;
}

if (strncmp(buf,stopcode,strlen(stopcode))==0) {
if (ii == ID1_EXIOB_U1TOP) {
for (int nDataNumber = ii; nDataNumber < ID1_MAX_INF; nDataNumber++) {
database[nDataNumber] = 0;
}
}

infl = 0;
continue;
}

if (strncmp(&buf[14], " DD ", 4) == 0) {
if ((cpnt=strchr(buf, ';')) != NULL) {
*cpnt = '';
}

if (ii >= ID1_IOB_TOP && ii < ID1_IOB_PIOTSUP) {
if ((bpnt1 = strchr(cpnt + 1,'(')) != NULL && (bpnt2=strchr(cpnt + 1,')'))!=NULL && bpnt1 < bpnt2) {
*bpnt2 = '';
*(bpnt1 + BOADNAM_MAX + 1) = '';
strcpy(IOBname[ii-ID1_IOB_TOP], bpnt1 + 1);
}
}

if (ii >= ID1_EXIOB_U1TOP && ii < ID1_MAX_INF) {
if ((bpnt1 = strchr(cpnt + 1, '(')) != NULL && (bpnt2=strchr(cpnt+1,')'))!=NULL && bpnt1 < bpnt2) {
*bpnt2='';
*(bpnt1+BOADNAM_MAX+1)='';
strcpy(ExIOBname[ii-ID1_EXIOB_U1TOP], bpnt1 + 1);
}
}

for (cpnt = &buf[18]; cpnt != NULL;) {
if ((npnt=strchr(cpnt, ',')) != NULL)
*npnt='';
}

if (strchr(cpnt,'H')!=NULL) {
sscanf(cpnt,"%XH",&database[ii]);
} else {
database[ii]=atoi(cpnt);
}

ii++;
cpnt = npnt;

if (cpnt != NULL) {
cpnt++;
}
}
}
}

fclose(fp);
} else {
State=-1;
}

Когда я компилирую эту функцию в Visual Studio 2008, она выдает ошибку при strcpy(IOBname[ii],""); как ниже.

ошибка C2220: предупреждение рассматривается как ошибка — файл объекта не создан

Как исправить эту ошибку?

21

Решение

Ошибка говорит о том, что предупреждение было обработано как ошибка. Поэтому ваша проблема — предупреждающее сообщение! Проверьте их и исправьте их.

Если вы не знаете, как их найти: откройте Error List (View > Error List) и нажмите на Warning,

23

Другие решения

Идти к project properties -> configurations properties -> C/C++ -> treats warning as error -> No (/WX-),

10

Это сообщение об ошибке очень запутанно. Я просто исправил другие «предупреждения» в своем проекте, и у меня действительно было только одно (простое):

предупреждение C4101: ‘i’: локальная переменная без ссылки

После того, как я прокомментировал это неиспользованным iи скомпилировал его, другая ошибка исчезла.

5

Как примечание, вы можете включить / отключить отдельные предупреждения, используя #pragma, Вы можете взглянуть на документацию Вот

Из документации:

// pragma_warning.cpp
// compile with: /W1
#pragma warning(disable:4700)
void Test() {
int x;
int y = x;   // no C4700 here
#pragma warning(default:4700)   // C4700 enabled after Test ends
}

int main() {
int x;
int y = x;   // C4700
}

3

Это предупреждение о небезопасном использовании strcpy. Пытаться IOBname[ii]=''; вместо.

1

При создании проекта я получаю следующую ошибку. Несмотря на то, что я устанавливаю для свойства «обрабатывать предупреждение как ошибку» значение «НЕТ», я получаю следующее:

error C2220: warning treated as error - no object file is created.

Может ли кто-нибудь помочь мне решить эту проблему? Заранее спасибо.

4 ответы

Компания документация для C2220 предлагает компилировать с более низким уровнем предупреждения. Он также показывает, что предупреждение, рассматриваемое как опция ошибки, реализовано как флаг компилятора: / WX. Таким образом, вы можете найти этот текст в файле .vcproj и вручную удалить его из файла.

Создан 01 июн.

Я получил «ошибка C2220: предупреждение рассматривается как ошибка — объектный файл не создается». в приведенном ниже коде.
Однажды я изменился тип данных от общего до Int , ошибка устранена.

int colNum=0;
unsigned int total=123;
for (colNum=0;colNum<total;colNum++) {

Создан 14 июля ’14, 21:07

#pragma warning(disable : 4146)

Установите это на уровне файла вместо изменения настроек проекта.

Создан 03 сен.

Возможно, вы забыли добавить заголовок. Именно там вы получите первое предупреждение и посмотрите, в каком файле заголовка определено.

С уважением

Создан 01 июн.

Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками

visual-studio
visual-studio-2005

or задайте свой вопрос.

Понравилась статья? Поделить с друзьями:
  • Error c2169 intrinsic function cannot be defined
  • Error c2146 синтаксическая ошибка отсутствие перед идентификатором
  • Error c2144 синтаксическая ошибка перед int требуется
  • Error c2144 syntax error void should be preceded by
  • Error c2144 syntax error int should be preceded by