Search Results

Search found 5842 results on 234 pages for 'compiler warnings'.

Page 9/234 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • C# Why does calling an interface member from a class generate an error?

    - by Jack
    So I have an interface: interface IFoo { int Bar(); int this[int i] {get; set;} } And a class that derives from it class Foo : IFoo { public int IFoo.Bar() { //Implementation { public int IFoo.this[int i] { //Implementation } } Now, I try to do this: var fooey = new Foo(); int i = Fooey.Bar(); or this: int i = Fooey[4]; I would expect these to work properly. However, the compiler generates an error as if such members don't exist. Why is that? I am aware I can cast Foo as IFoo, but I am also aware that casting is costly to performance, which is often the reason to use interfaces in the first place. EDIT 1: These are the errors generated 'Foo' does not contain a definition for 'Bar' and no extension method 'Bar' accepting a first argument of type 'Foo' could be found (are you missing a using directive or an assembly reference?) "Cannot apply indexing to an expression of type 'Foo'"

    Read the article

  • How do I create my own programming language and a compiler for it

    - by Dave
    I am thorough with programming and have come across languages including BASIC, FORTRAN, COBOL, LISP, LOGO, Java, C++, C, MATLAB, Mathematica, Python, Ruby, Perl, JavaScript, Assembly and so on. I can't understand how people create programming languages and devise compilers for it. I also couldn't understand how people create OS like Windows, Mac, UNIX, DOS and so on. The other thing that is mysterious to me is how people create libraries like OpenGL, OpenCL, OpenCV, Cocoa, MFC and so on. The last thing I am unable to figure out is how scientists devise an assembly language and an assembler for a microprocessor. I would really like to learn all of these stuff and I am 15 years old. I always wanted to be a computer scientist someone like Babbage, Turing, Shannon, or Dennis Ritchie. I have already read Aho's Compiler Design and Tanenbaum's OS concepts book and they all only discuss concepts and code in a high level. They don't go into the details and nuances and how to devise a compiler or operating system. I want a concrete understanding so that I can create one myself and not just an understanding of what a thread, semaphore, process, or parsing is. I asked my brother about all this. He is a SB student in EECS at MIT and hasn't got a clue of how to actually create all these stuff in the real world. All he knows is just an understanding of Compiler Design and OS concepts like the ones that you guys have mentioned (i.e. like Thread, Synchronization, Concurrency, memory management, Lexical Analysis, Intermediate code generation and so on)

    Read the article

  • How do I create my own programming language and a compiler for it

    - by Dave
    I am thorough with programming and have come across languages including BASIC, FORTRAN, COBOL, LISP, LOGO, Java, C++, C, MATLAB, Mathematica, Python, Ruby, Perl, Javascript, Assembly and so on. I can't understand how people create programming languages and devise compilers for it. I also couldn't understand how people create OS like Windows, Mac, UNIX, DOS and so on. The other thing that is mysterious to me is how people create libraries like OpenGL, OpenCL, OpenCV, Cocoa, MFC and so on. The last thing I am unable to figure out is how scientists devise an assembly language and an assembler for a microprocessor. I would really like to learn all of these stuff and I am 15 years old. I always wanted to be a computer scientist some one like Babbage, Turing, Shannon, or Dennis Ritchie. I have already read Aho's Compiler Design and Tanenbaum's OS concepts book and they all only discuss concepts and code in a high level. They don't go into the details and nuances and how to devise a compiler or operating system. I want a concrete understanding so that I can create one myself and not just an understanding of what a thread, semaphore, process, or parsing is. I asked my brother about all this. He is a SB student in EECS at MIT and hasn't got a clue of how to actually create all these stuff in the real world. All he knows is just an understanding of Compiler Design and OS concepts like the ones that you guys have mentioned (ie like Thread, Synchronisation, Concurrency, memory management, Lexical Analysis, Intermediate code generation and so on)

    Read the article

  • "Temporary object" warning - is it me or the compiler?

    - by Roddy
    The following snippet gives the warning: [C++ Warning] foo.cpp(70): W8030 Temporary used for parameter '_Val' in call to 'std::vector<Base *,std::allocator<Base *> >::push_back(Base * const &)' .. on the indicated line. class Base { }; class Derived: public Base { public: Derived() // << warning disappears if constructor is removed! { }; }; std::vector<Base*> list1; list1.push_back(new Base); list1.push_back(new Derived); // << Warning on this line! Compiler is Codegear C++Builder 2007. Oddly, if the constructor for Derived is deleted, the warning goes away... Is it me or the compiler?

    Read the article

  • In asp.Net, writing code in the control tag generates compile error

    - by Nour Sabouny
    Hi this is really strange !! But look at the following asp code: <div runat="server" id="MainDiv"> <%foreach (string str in new string[]{"First#", "Second#"}) { %> <div id="<%=str.Replace("#","div") %>"> </div> <%} %> </div> now if you put this code inside any web page (and don't worry about the moral of this code, I made it just to show the idea) you'll get this error : Compiler Error Message: CS1518: Expected class, delegate, enum, interface, or struct Of course the error has nothing to do with the real problem, I searched for the code that was generated by asp.net and figured out the following : private void @__RenderMainDiv(System.Web.UI.HtmlTextWriter @__w, System.Web.UI.Control parameterContainer) { @__w.Write("\r\n "); #line 20 "blabla\blabla\Default.aspx" foreach (string str in new string[] { "First#", "Second#" }) { #line default #line hidden @__w.Write("\r\n <div id=\""); #line 22 "blabla\blabla\Default.aspx" @__w.Write(str.Replace("#", "div")); #line default #line hidden @__w.Write("\">\r\n "); } This is the code that was generated from the asp page and this is the method that is meant to render our div (MainDiv), I found out that there is a missing bracket "}" that closes the method or the (for loop). now the problem has three parts: 1- first you should have a server control (in our situation is the MainDiv) and I'm not sure if it is only the div tag. 2- HTML control inside the server control and a code inside it using the double quotation mark ( for example <div id="<%=str instead of <div id='<%=str. 3-Any keyword which has block brackets e.g.:for{},while{},using{}...etc. now removing any part, will solve the problem !!! how is this happening ?? any ideas ? BTW: please help me to make the question more obvious, because I couldn't find the best words to describe the problem.

    Read the article

  • The Dispose Pattern (and FxCop warnings)

    - by Scott Dorman
    [This is actually a response to Bill’s blog post, but since it isn’t possible to leave this as a comment on his blog it’s a post here.] There are many different ways to implement the Dispose pattern correctly. Some are (in my opinion) better than others. In Bill’s blog post he presents a particular pattern, which is an excerpt from his book (Effective C#). The issue centers around the fact that a reader took the code sample presented in the book and ran FxCop (Code Analysis) on it, which generated a warning: “Ensure that base.Dispose() is always called.” The “lesson learned” that Bill presents is that “tools are there to help us, not control us.” While I completely agree with the belief that tools are there to help us, I think it’s important to understand why FxCop is raising this particular warning. The code presented in Bill’s book looks like: // Have its own disposed flag.private bool disposed = false;protected override void Dispose(bool isDisposing){ // Don't dispose more than once. if (disposed) return; if (isDisposing) { // TODO: free managed resources here. } // TODO: free unmanaged resources here. // Let the base class free its resources. // Base class is responsible for calling // GC.SuppressFinalize( ) base.Dispose(isDisposing); // Set derived class disposed flag: disposed = true;} This code does follow all of the guidelines for implementing the Dispose pattern. In this case, it’s presumably part of a larger example showing how to implement the pattern as part of a base class. The reason FxCop is warning you about this code is the first if statement in the Dispose method, which will cause the method to exit if disposed is true. The problem here is that there is the possibility that if the disposed flag is true, the call to base.Dispose() will never be executed. As Bill points out, it is possible for some other code elsewhere in the class to set this flag. He states that this is an “unlikely occurrence.” While that is probably true, it can be a potentially dangerous assumption to make and is one that can be easily corrected. By changing the code slightly you can remove this assumption and correct the FxCop violation. private bool disposed = false;protected override void Dispose(bool disposing){ if (!disposed) { if (disposing) { // Dispose managed resources. } // Dispose unmanaged resources. disposed = true; } base.Dispose(disposing);} Using this implementation allows the call to base.Dispose() to always occur, which ensures that the the disposal chain is always properly followed. Technorati Tags: .NET,C#,Dispose Pattern

    Read the article

  • Coherence Warnings in WLS

    - by john.graves(at)oracle.com
    With 11g (10.3.4 WLS), coherence is now built into many applications.  I’ve been noticing errors in my OSB logs like these:####<10/03/2011 10:45:40 AM EST> <Warning> <Coherence> <osb-jeos> <osb_server1> <Logger@324239121 3.6.0.4> <<anonymous>> <> <583c1 0bfdbd326ba:-8c38159:12e9d02c829:-8000-0000000000000003> <1299714340643> <BEA-000000> <Oracle Coherence 3.6.0.4 (member=n/a): Unic astUdpSocket failed to set receive buffer size to 714 packets (1023KB); actual size is 12%, 89 packets (127KB). Consult your OS do cumentation regarding increasing the maximum socket buffer size. Proceeding with the actual value may cause sub-optimal performanc e.> ####<10/03/2011 10:45:40 AM EST> <Warning> <Coherence> <osb-jeos> <osb_server1> <Logger@324239121 3.6.0.4> <<anonymous>> <> <583c1 0bfdbd326ba:-8c38159:12e9d02c829:-8000-0000000000000003> <1299714340650> <BEA-000000> <Oracle Coherence 3.6.0.4 (member=n/a): Pref erredUnicastUdpSocket failed to set receive buffer size to 1428 packets (1.99MB); actual size is 6%, 89 packets (127KB). Consult y our OS documentation regarding increasing the maximum socket buffer size. Proceeding with the actual value may cause sub-optimal p erformance.> ####<10/03/2011 10:45:40 AM EST> <Warning> <Coherence> <osb-jeos> <osb_server1> <Logger@324239121 3.6.0.4> <<anonymous>> <> <583c1 0bfdbd326ba:-8c38159:12e9d02c829:-8000-0000000000000003> <1299714340659> <BEA-000000> <Oracle Coherence 3.6.0.4 (member=n/a): Mult icastUdpSocket failed to set receive buffer size to 714 packets (1023KB); actual size is 12%, 89 packets (127KB). Consult your OS documentation regarding increasing the maximum socket buffer size. Proceeding with the actual value may cause sub-optimal performa nce.> I was able to “fix” this on my ubuntu system by adding the following lines to the /etc/sysctl.conf file:# Setup networking for coherence # maximum receive socket buffer size, default 131071 net.core.rmem_max = 2000000 # maximum send socket buffer size, default 131071 net.core.wmem_max = 1000000 # default receive socket buffer size, default 65535 net.core.rmem_default = 2524287 # default send socket buffer size, default 65535 net.core.wmem_default = 2524287 .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }   .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

    Read the article

  • xvkbd broken with warnings

    - by Maxrunner
    Im using the latest version of ubunto and i cant run xvkbd properly, i get these errors: $ xvkbd Warning: Cannot convert string "--lucidatypewriter-bold-r--*-12---*---iso8859-1" to type FontStruct xvkbd: Mode_switch not available as a modifier xvkbd: although ISO_Level3_Shift is used instead, AltGr may not work correctly Warning: Cannot convert string "--lucida-bold-i--*-14---*---iso8859-1" to type FontStruct xvkbd: Mode_switch not available as a modifier xvkbd: although ISO_Level3_Shift is used instead, AltGr may not work correctly how can i solve this?, im trying to use this with xbindkeys.

    Read the article

  • Compiler Dependencies [closed]

    - by asghar ashgari
    I'm a newbie researcher who's passion is programming languages (Web era). I'm wondering why all the Web frameworks and Web-based general purposes languages, have a huge number of dependencies when you want to install and then use (e.g., extend, alternate, etc.) their compilers. For example, Ruby on Rails or Scala. If I want to download their source code, and try to build it again, to me at least, feels like a can of worms. I have a MAC, so I need to install MACports, then update my XCode, then get the compiler source code that has bunch of other dependencies, then its hard to set things up; just to see the installed open-source compiler works fine.

    Read the article

  • Google Closure Compiler - what does the name mean?

    - by mikez302
    I am curious about the Google Closure Compiler. Why did they name it that? Does it have anything to do with lexical closures? EDIT: I tried researching it in the FAQ and documentation, as well as doing Google searches such as "closure compiler name". I couldn't find anything definite, hence the reason I am asking. I don't think I will get a profoundly helpful answer but I was hoping that I could at least satisfy my curiosity. I am not trying to solve a specific problem. I am just curious.

    Read the article

  • Switching from Debug into Release Mode with VS2010 as IDE and Intel C++ Compiler 13

    - by Drazick
    I have a code of a Plug In from an SDK. The code is in Debug Mode. I use Intel Compiler which only applies optimizations in Release Mode. Under configuration manager of the project only "Debug" mode is defined. How could I switch to "Release" mode and enable all Intel Compiler's optimizations? If I enable them on debug mode nothing is applied (Empty Report). I couldn't find the trick to do so. Thank You.

    Read the article

  • Theory: Can JIT Compiler be used to parse the whole program first, then execute later?

    - by unknownthreat
    Normally, JIT Compiler works by reads the byte code, translate it into machine code, and execute it. This is what I understand, but in theory, is it possible to make the JIT Compiler parses the whole program first, then execute the program later as machine code? I do not know how JIT Compiler works technically and exactly, so I don't know any feasibility in this case. But theoretically, is it possible? Or am I doing it wrong?

    Read the article

  • Parantheses around method invokation: why is the compiler complaining about assignment?

    - by polygenelubricants
    I know why the following code doesn't compile: public class Main { public static void main(String args[]) { main((null)); // this is fine! (main(null)); // this is NOT! } } What I'm wondering is why my compiler (javac 1.6.0_17, Windows version) is complaining "The left hand side of an assignment must be a variable". I'd expect something like "Don't put parantheses around a method invokation, dummy!", instead. So why is the compiler making a totally unhelpful complaint about something that is blatantly irrelevant? Is this the result of an ambiguity in the grammar? A bug in the compiler? If it's the former, could you design a language such that a compiler would never be so off-base about a syntax error like this?

    Read the article

  • Is a C++ compiler allowed to emit different machine code compiling the same program?

    - by sharptooth
    Consider a situation. We have some specific C++ compiler, a specific set of compiler settings and a specific C++ program. We compile that specific programs with that compiler and those settings two times, doing a "clean compile" each time. Should the machine code emitted be the same (I don't mean timestamps and other bells and whistles, I mean only real code that will be executed) or is it allowed to vary from one compilation to another?

    Read the article

  • why it is up to the compiler to decide what value to assign when assigning an out-of-range value to

    - by Allopen
    in C++ Primer 4th edition 2.1.1, it says "when assigning an out-of-range value to a signed type, it is up to the compiler to decide what value to assign". I can't understand it. I mean, if you have code like "char 5 = 299", certainly the compiler will generate asm code like "mov BYTE PTR _sc$[ebp], 43"(VC) or "movb $43, -2(%ebp)"(gcc+mingw), it IS decided by the compiler. but what if we assign a value that is given by the user input? like, via command line? and the asm code generated will be "movb %al, -1(%ebp)"(gcc+mingw) and " mov cl, BYTE PTR _i$[ebp] mov BYTE PTR _sc$[ebp], cl "(VC), so now how can compiler decide what will happen? I think now it is decided by the CPU. Can you give me a clear explanation?

    Read the article

  • Need help regarding one LALR(1) parsing.

    - by AppleGrew
    I am trying to parse a context-free language, called Context Free Art. I have created its parser in Javascript using a YACC-like JS LALR(1) parser generator JSCC. Take the example of following CFA (Context Free Art) code. This code is a valid CFA. startshape A rule A { CIRCLE { s 1} } Notice the A and s in above. s is a command to scale the CIRCLE, but A is just a name of this rule. In the language's grammar I have set s as token SCALE and A comes under token STRING (I have a regular expression to match string and it is at the bottom of of all tokens). This works fine, but in the below case it breaks. startshape s rule s { CIRCLE { s 1} } This too is a perfectly valid code, but since my parser marks s after rule as SCALE token so it errors out saying that it was expecting STRING. Now my question is, if there is any way to re-write the production rules of the parser to account for this? The related production rule is:- rule: RULE STRING '{' buncha_replacements '}' [* rule(%2, 1) *] | RULE STRING RATIONAL '{' buncha_replacements '}' [* rule(%2, 1*%3) *] ; One simple solution I can think of is create a copy of above rule with STRING replaced by SCALE, but this is just one of the many similar rules which would need such fixing. Furthermore there are many other terminals which can get matched to STRING. So that means way too many rules!

    Read the article

  • Benefits of 'Optimize code' option in Visual Studio build

    - by gt
    Much of our C# release code is built with the 'Optimize code' option turned off. I believe this is to allow code built in Release mode to be debugged more easily. Given that we are creating fairly simple desktop software which connects to backend Web Services, (ie. not a particularly processor-intensive application) then what if any sort of performance hit might be expected? And is any particular platform likely to be worse affected? Eg. multi-processor / 64 bit.

    Read the article

  • When to use certain optimizations such as -fwhole-program and -fprofile-generate with several shared libraries

    - by James
    Probably a simple answer; I get quite confused with the language used in the GCC documentation for some of these flags! Anyway, I have three libraries and a programme which uses all these three. I compile each of my libraries seperately with individual (potentially) different sets of warning flags. However, I compile all three libraries with the same set of optimisation flags. I then compile my main programme linking in these three libraries with its own set of warning flags and the same optimisation flags used during the libraries' compilation. 1) Do I have to compile the libraries with optimisation flags present or can I just use these flags when compiling the final programme and linking to the libraries? If the latter, will it then optimise all or just some (presumably that which is called) of the code in these libraries? 2) I would like to use -fwhole-program -flto -fuse-linker-plugin and the linker plugin gold. At which stage do I compile with these on ... just the final compilation or do these flags need to be present during the compilation of the libraries? 3) Pretty much the same as 2) however with, -fprofile-generate -fprofile-arcs and -fprofile-use. I understand one first runs a programme with generate, and then with use. However, do I have to compile each of the libraries with generate/use etc. or just the final programme? And if it is just the last programme, when I then compeil with -fprofile-use will it also optimise the libraries functionality? Many thanks, James

    Read the article

  • Delphi: All constants are constant, but some are more constant than others?

    - by Ian Boyd
    Consider: clHotlight: TColor = $00FF9933; clLink = clHotLight; //alias of clHotlight [Error] file.pas: Constant expression expected and the alternate wording that works: clHotlight = TColor($00FF9933); clLink = clHotLight; //alias of clHotlight Explain. Then consider: AdministratorGUID: TGUID = '{DE44EEA0-6712-11D4-ADD4-0006295717DA}'; SuperuserGUID = AdministratorGUID; //alias of AdministratorGUID [Error] file.pas: Constant expression expected And fix.

    Read the article

  • Languages and VMs: Features that are hard to optimize and why

    - by mrjoltcola
    I'm doing a survey of features in preparation for a research project. Name a mainstream language or language feature that is hard to optimize, and why the feature is or isn't worth the price paid, or instead, just debunk my theories below with anecdotal evidence. Before anyone flags this as subjective, I am asking for specific examples of languages or features, and ideas for optimization of these features, or important features that I haven't considered. Also, any references to implementations that prove my theories right or wrong. Top on my list of hard to optimize features and my theories (some of my theories are untested and are based on thought experiments): 1) Runtime method overloading (aka multi-method dispatch or signature based dispatch). Is it hard to optimize when combined with features that allow runtime recompilation or method addition. Or is it just hard, anyway? Call site caching is a common optimization for many runtime systems, but multi-methods add additional complexity as well as making it less practical to inline methods. 2) Type morphing / variants (aka value based typing as opposed to variable based) Traditional optimizations simply cannot be applied when you don't know if the type of someting can change in a basic block. Combined with multi-methods, inlining must be done carefully if at all, and probably only for a given threshold of size of the callee. ie. it is easy to consider inlining simple property fetches (getters / setters) but inlining complex methods may result in code bloat. The other issue is I cannot just assign a variant to a register and JIT it to the native instructions because I have to carry around the type info, or every variable needs 2 registers instead of 1. On IA-32 this is inconvenient, even if improved with x64's extra registers. This is probably my favorite feature of dynamic languages, as it simplifies so many things from the programmer's perspective. 3) First class continuations - There are multiple ways to implement them, and I have done so in both of the most common approaches, one being stack copying and the other as implementing the runtime to use continuation passing style, cactus stacks, copy-on-write stack frames, and garbage collection. First class continuations have resource management issues, ie. we must save everything, in case the continuation is resumed, and I'm not aware if any languages support leaving a continuation with "intent" (ie. "I am not coming back here, so you may discard this copy of the world"). Having programmed in the threading model and the contination model, I know both can accomplish the same thing, but continuations' elegance imposes considerable complexity on the runtime and also may affect cache efficienty (locality of stack changes more with use of continuations and co-routines). The other issue is they just don't map to hardware. Optimizing continuations is optimizing for the less-common case, and as we know, the common case should be fast, and the less-common cases should be correct. 4) Pointer arithmetic and ability to mask pointers (storing in integers, etc.) Had to throw this in, but I could actually live without this quite easily. My feelings are that many of the high-level features, particularly in dynamic languages just don't map to hardware. Microprocessor implementations have billions of dollars of research behind the optimizations on the chip, yet the choice of language feature(s) may marginalize many of these features (features like caching, aliasing top of stack to register, instruction parallelism, return address buffers, loop buffers and branch prediction). Macro-applications of micro-features don't necessarily pan out like some developers like to think, and implementing many languages in a VM ends up mapping native ops into function calls (ie. the more dynamic a language is the more we must lookup/cache at runtime, nothing can be assumed, so our instruction mix is made up of a higher percentage of non-local branching than traditional, statically compiled code) and the only thing we can really JIT well is expression evaluation of non-dynamic types and operations on constant or immediate types. It is my gut feeling that bytecode virtual machines and JIT cores are perhaps not always justified for certain languages because of this. I welcome your answers.

    Read the article

  • 'Lexical' scoping of type parameters in C#

    - by leppie
    I have 2 scenarios. This fails: class F<X> { public X X { get; set; } } error CS0102: The type 'F' already contains a definition for 'X' This works: class F<X> { class G { public X X { get; set; } } } The only logical explanation is that in the second snippet the type parameter X is out of scope, which is not true... Why should a type parameter affect my definitions in a type? IMO, for consistency, either both should work or neither should work. Any other ideas? PS: I call it 'lexical', but it probably is not not the correct term.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >