compiler-warnings

Razor Compiler Warning/Errors - ASP.NET MVC 4

梦想与她 提交于 2019-11-30 11:36:13
问题 I have an issue which seems to have been reported here: Need razor view engine auto-complete to work in a class library? My issue is the following Warning: G:\Accountable\Accountable\Views\LedgerUser\EditorTemplates\LedgerServiceViewModel.cshtml: ASP.NET runtime error: There is no build provider registered for the extension '.cshtml'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web'

How does scoped_lock avoid emitting an “unused variable” warning?

时光毁灭记忆、已成空白 提交于 2019-11-30 11:30:15
boost::mutex::scoped_lock is a handy RAII wrapper around locking a mutex. I use a similar technique for something else: a RAII wrapper around asking a data interface to detach from/re-attach to a serial device. What I can't figure out, though, is why in the code below only my object mst — whose instantiation and destruction do have side effects — causes g++ to emit an "unused variable" warning error whereas l manages to remain silent. Do you know? Can you tell me? [generic@sentinel ~]$ cat test.cpp #include <boost/shared_ptr.hpp> #include <boost/thread/mutex.hpp> #include <iostream> struct

How to overcome pointless C++ compiler warnings elegantly?

谁都会走 提交于 2019-11-30 10:51:54
This question is not bound to any specific compiler warning, the following is just an example. Currently when I want a loop that checks an exit condition inside: while( true ) { doSomething(); if( condition() ) { break; } doSomethingElse(); } I can't just write that in Visual C++ - it will emit a C4127 conditional expression is constant warning. The compiler will wave it in my face although it's quite obvious that while(true) can't have been written accidentially. Suppose I want code that compiles without warnings. There're workarounds at my service. Workaround one is to use for(;;) but it

Conditional references in .NET project, possible to get rid of warning?

你说的曾经没有我的故事 提交于 2019-11-30 10:36:13
问题 I have two references to a SQLite assembly, one for 32-bit and one for 64-bit, which looks like this (this is a test project to try to get rid of the warning, don't get hung up on the paths): <Reference Condition=" '$(Platform)' == 'x64' " Include="System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=AMD64"> <SpecificVersion>True</SpecificVersion> <HintPath>..\..\LVK Libraries\SQLite3\version_1.0.65.0\64-bit\System.Data.SQLite.DLL<

C Returning char[] Warning “returns address of local variable” [duplicate]

纵饮孤独 提交于 2019-11-30 10:06:15
This question already has an answer here: Returning an address of local variable behaviour [duplicate] 2 answers This is a portion of a homework assignment. I am trying to read and return a single line of a file in my method getLine. char *getLine(FILE *input) { char line[30]; if(fgets(line, sizeof(line), input)!=NULL) { return line; }else{ return NULL; } } This would seem to work from what I have been taught regarding pointers, however I am unable to remove the warning message warning: function returns address of local variable [enabled by default] . This warning is referring to the line

How can I make gfortran or ifort tell me when it implicitly promotes a REAL(4) to a REAL(8)?

懵懂的女人 提交于 2019-11-30 09:38:51
问题 I am tasked with changing the precision of parts of an HPC application, bearing in mind that it makes heavy reliance on auto-vectorisation. It is therefore useful for the compiler to inform me when conversions of any type of floating point conversion occurs (as this could have a serious performance impact). The -Wconversion flag sounds like it should suit my needs: -Wconversion Warn about implicit conversions between different types. https://gcc.gnu.org/onlinedocs/gcc-4.1.0/gfortran/Warning

Save and reprint warnings for successfully-compiled files on subsequent builds?

99封情书 提交于 2019-11-30 09:05:11
问题 When repeatedly building a project, when there are warnings but no errors in a translation unit, the main source file is typically not recompiled. This can make it difficult to work through errors and warnings to attempt to get the project to build with no warnings. Typically one must keep iteratively building until all errors are taken care of, then do a full clean and build to ensure that there are no warnings (as well as to ensure that the previously-completed build wasn't a "fluke" caused

How do I enable the 6000 series warnings (code analysis warnings) in MSVC++?

a 夏天 提交于 2019-11-30 08:52:36
问题 Even warning level 4 and "all warnings" does not make the 6000 series warnings appear. 回答1: Actually enabling these "Code Analysis" warnings has it's own dialog. In your project properties, you must check "Enable Code Analysis on Build" to make it work. This code should then show error 6246: #include <stdio.h> int main() { int x ; { int x = 6 ; printf( "%d\n", x ) ; } } warning C6246: Local declaration of 'x' hides declaration of the same name in outer scope. This setting appears to be

Why this “Implicit declaration of function 'X'”? [duplicate]

百般思念 提交于 2019-11-30 08:39:00
This question already has an answer here: warning: implicit declaration of function 6 answers I wrote a simple program to find the Sum, average, biggest and smallest number of 3 numbers. It lets the user to input three (integer) numbers and return the sum, average, max and min. It has no errors but a warning. Here is my source code: main.c: #include <stdio.h> int main() { int num1, num2, num3, sum, max, min, avg; printf("Enter Three \"Integer\" Numbers:"); scanf("%i%i%i", &num1, &num2, &num3); sum = summation(&num1, &num2, &num3); avg = average(&sum); max = max_val(&num1, &num2, &num3); min =

Is there an equivalent of gcc's -Wshadow in visual C++

柔情痞子 提交于 2019-11-30 07:57:59
问题 -Wshadow will "Warn whenever a local variable shadows another local variable.". Is there an equivalent in Visual C++ (2008)? I tried /W4 but it didn't pick up on it. I also tried Cppcheck but that didn't see it either. e.g. if I inadvertently do: class A { private: int memberVar; public: void fn() { int memberVar = 27; } }; I would really like to know about it! 回答1: I am afraid no. You could perhaps try compiling your code with Clang: it has this warning (and a lot of others) it has a