I am using microsoft visual c++ 2010. when I compile, it gives me several warnings, and the ocassional errors. However, most of these warnings are in the header files that are included in the program. Is there a setting that only displays errors/warnings in the program and not the includes?
Not looking for how to fix the header errors, just a setting.

Please post your code and the errors you're getting. Just because the errors are being thrown in compiler-provided headers doesn't mean your code isn't wrong.

Edited 5 Years Ago by Narue: n/a

Please post your code and the errors you're getting. Just because the errors are being thrown in compiler-provided headers doesn't mean your code isn't wrong.

#include "stdafx.h"
#include <stdio.h>
#include "simpio.h"
#include "genlib.h"
#include "Windows.h"
#define size 3
void lessnei(int numarray[5][5]);

main()
      {
      int less;
      int numArray[size+2][size+2];
      printf("Enter the next element\n");//1,1
      less=GetInteger();
      numArray[1][1]=less;
      numArray[1][0]=less-1;
      numArray[0][0]=less-1;
      numArray[0][1]=less-1;
      numArray[0][2]=less-1;
      numArray[2][1]=less-1;
      printf("Enter the next element\n");//1,2
      less=GetInteger();
      numArray[1][2]=less;
      numArray[0][3]=less-1;
      printf("Enter the next element\n");//1,3
      less=GetInteger();
      numArray[1][3]=less;
      numArray[0][4]=less-1;
      numArray[1][4]=less-1;
      numArray[2][4]=less-1;
      printf("Enter the next element\n");//2,1
      less=GetInteger();
      numArray[2][1]=less;
      numArray[3][0]=less-1;
      printf("Enter the next element\n");//middle
      less=GetInteger();
      numArray[2][2]=less;
      printf("Enter the next element\n");//2,3
      less=GetInteger();
      numArray[2][3]=less;
      numArray[3][4]=less-1;
      printf("Enter the next element\n");//3,1
      less=GetInteger();
      numArray[3][1]=less;
      numArray[4][0]=less-1;
      numArray[4][1]=less-1;
      numArray[4][2]=less-1;
      printf("Enter the next element\n");//3,2
      less=GetInteger();
      numArray[3][2]=less;
      numArray[4][2]=less-1;
      numArray[4][3]=less-1; 
      printf("Enter the next element\n");//3,2
      less=GetInteger();
      numArray[3][3]=less;
      numArray[4][3]=less-1;
      numArray[4][4]=less-1;
      lessnei(numArray);
      getchar();
      }
void lessnei(int numarray[5][5])
      {
      bool isbig1, isbig2, isbig3, isbig4, isbig5, isbig6, isbig7, isbig8;
      int row, column, itemrc;
      for(row=1; row<=size; row++)
      {
      for(column=1; column<=size; column++)
      {
      itemrc=numarray[row][column];
      isbig1=itemrc>numarray[row+1][column];
      isbig2=itemrc>numarray[row][column+1];
      isbig3=itemrc>numarray[row+1][column+1];
      isbig4=itemrc>numarray[row-1][column];
      isbig5=itemrc>numarray[row][column-1];
      isbig6=itemrc>numarray[row-1][column-1];
      isbig7=itemrc>numarray[row+1][column-1];
      isbig8=itemrc>numarray[row-1][column+1];
      if(isbig1&&isbig2&&isbig3&&isbig4&&isbig5&&isbig6&&isbig7&&isbig8)
      printf("%d in (%d,%d)", numarray[row][column], row-1, column-1);
      }
      }
      }

Errors:

1>------ Build started: Project: proj2_open, Configuration: Debug Win32 ------
1>  proj2_open.cpp
1>c:\program files\microsoft visual studio 10.0\vc\include\simpio.h(44): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\string.h(188) : see declaration of 'strncpy'
1>c:\program files\microsoft visual studio 10.0\vc\include\simpio.h(57): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'strcpy'
1>c:\program files\microsoft visual studio 10.0\vc\include\simpio.h(98): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(325) : see declaration of 'sscanf'
1>c:\program files\microsoft visual studio 10.0\vc\include\simpio.h(135): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(325) : see declaration of 'sscanf'
1>c:\program files\microsoft visual studio 10.0\vc\include\simpio.h(172): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(325) : see declaration of 'sscanf'
1>c:\users\the masroors\documents\visual studio 2010\projects\proj2_open\proj2_open\proj2_open.cpp(11): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Those warnings mean that Microsoft compilers now consider standard functions declared in string.h to be depreciated and unsafe to use. You can disable that warning, at your own risk, if you choose to ignore it. #pragma warning(disable: 4996) Put that somewhere at the top (after include files) of the *.c or *.cpp file(s).

You might want to start getting into the habit of using the newer and safer functions that are named in the warnings. Getting ahead of that game now will save you lots of headaches in the future.

Edited 5 Years Ago by Ancient Dragon: n/a

Okay.. New program... 2 things wrong...
code:

#include "stdafx.h"
#include <iostream.h>
#include "simpio.h"
#include <stdio.h>
#include "genlib.h"
#pragma warning(disable: 4068)

void main()
{
cout<<"hello"<<endl;
getchar();
}

Basically, display 'hello' and wait for a key to be pressed, but it just shows the output window and dissapears.
Also, the pragmas aren't working...
Errors:

1>------ Build started: Project: ride, Configuration: Debug Win32 ------
1>  ride.cpp
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(21): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(22): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(24): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(25): error C2146: syntax error : missing ';' before identifier 'ios'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(25): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(25): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(26): warning C4081: expected 'identifier'; found 'else'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(27): error C2146: syntax error : missing ';' before identifier 'ios_base'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(27): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(27): error C2378: 'ios' : redefinition; symbol cannot be overloaded with a typedef
1>          c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(25) : see declaration of 'ios'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(27): warning C4091: '' : ignored on left of 'int' when no variable is declared
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(28): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(30): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(31): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(33): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(34): error C2146: syntax error : missing ';' before identifier 'ostringstream'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(34): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(34): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(35): error C2146: syntax error : missing ';' before identifier 'istringstream'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(35): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(35): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(37): warning C4081: expected 'identifier'; found 'else'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(38): error C2146: syntax error : missing ';' before identifier 'ostrstream'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(38): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(38): error C2378: 'ostringstream' : redefinition; symbol cannot be overloaded with a typedef
1>          c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(34) : see declaration of 'ostringstream'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(38): warning C4091: '' : ignored on left of 'int' when no variable is declared
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(39): error C2146: syntax error : missing ';' before identifier 'istrstream'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(39): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(39): error C2378: 'istringstream' : redefinition; symbol cannot be overloaded with a typedef
1>          c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(35) : see declaration of 'istringstream'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(39): warning C4091: '' : ignored on left of 'int' when no variable is declared
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(40): error C2146: syntax error : missing ';' before identifier 'strstream'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(40): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(40): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(41): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(43): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(45): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(52): warning C4081: expected 'identifier'; found 'if'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(55): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(71): error C2371: 'ios' : redefinition; different basic types
1>          c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(27) : see declaration of 'ios'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(173): error C3861: 'isprint': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(183): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(184): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(197): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(198): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(210): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(211): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(223): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(224): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(236): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(237): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(268): error C2365: 'istream::tie' : redefinition; previous definition was 'data member'
1>          c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(262) : see declaration of 'istream::tie'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(304): error C2063: 'istream::tie' : not a function
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(449): warning C4068: unknown pragma
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(453): error C3861: 'G__charformatter': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(462): error C2365: 'endl' : redefinition; previous definition was 'function'
1>          c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(438) : see declaration of 'endl'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(463): error C2365: 'ends' : redefinition; previous definition was 'function'
1>          c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(439) : see declaration of 'ends'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(464): error C2365: 'flush' : redefinition; previous definition was 'function'
1>          c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(437) : see declaration of 'flush'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(465): error C2365: 'ws' : redefinition; previous definition was 'function'
1>          c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(440) : see declaration of 'ws'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(466): error C2365: 'WS' : redefinition; previous definition was 'function'
1>          c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(444) : see declaration of 'WS'
1>c:\program files\microsoft visual studio 10.0\vc\include\iostream.h(475): fatal error C1083: Cannot open include file: '_iostream': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Edited 5 Years Ago by fmasroor: n/a

Since we're resurrecting this mostly dead thread...


cout and endl live in the std namespace.

Either:

using namespace std;

or

using std::cout;
using std::endl;

or

std::cout and std::endl every time you use them

Also, how many times am I going to have to say this before you read it? Why come here and ask questions if you don't listen to the answers?

should be

int main()

Edited 5 Years Ago by Moschops: n/a

This article has been dead for over six months. Start a new discussion instead.