Search Results

Search found 724 results on 29 pages for 'constants'.

Page 18/29 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • How do I inhibit "note C6311" in Microsoft C compiler?

    - by piCookie
    In this maximally clipped source example, the manifest constant FOOBAR is being redefined. This is deliberate, and there is extra code in the live case to make use of each definition. The pragma was added to get rid of a warning message, but then a note appeared, and I don't seem to find a way to get rid of the note. I've been able to modify this particular source to #undef between the #define, but I would like to know if there's a way to inhibit the note without requiring #undef, since there are multiple constants being handled the same way. #pragma warning( disable : 4005 ) // 'identifier' : macro redefinition #define FOOBAR FOO #define FOOBAR BAR The compiler banner and output are as follows Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. message.c message.c(3) : note C6311: message.c(2) : see previous definition of 'FOOBAR'

    Read the article

  • arguments into instance methods in ruby

    - by aharon
    So, I'd like to be able to make a call x = MyClass.new('good morning', 'good afternoon', 'good evening', 'good night', ['hello', 'goodbye']) that would add methods to the class whose values are the values of the arguments. So now: p x.methods #> [m_greeting, a_greeting, e_greeting, n_greeting, r_greeting, ...] And p x.m_greeting #> "good morning" p x.r_greeting #> ['hello', 'goodbye'] I realize that this is sort of what instance variables are to do (and that if I wanted them immutable I could make them frozen constants) but, for reasons beyond my control, I need to make methods instead. Thanks!

    Read the article

  • Does MATLAB perform tail call optimization?

    - by Shea Levy
    I've recently learned Haskell, and am trying to carry the pure functional style over to my other code when possible. An important aspect of this is treating all variables as immutable, i.e. constants. In order to do so, many computations that would be implemented using loops in an imperative style have to be performed using recursion, which typically incurs a memory penalty due to the allocation a new stack frame for each function call. In the special case of a tail call (where the return value of a called function is immediately returned to the callee's caller), however, this penalty can be bypassed by a process called tail call optimization (in one method, this can be done by essentially replacing a call with a jmp after setting up the stack properly). Does MATLAB perform TCO by default, or is there a way to tell it to?

    Read the article

  • Calculating Length Based on Sensor Data

    - by BSchlinker
    I've got an IR sensor which writes its current information to a token which I then interpret in a C# application. That's all good -- no problems there, heres my code: SetLabelText(tokens [1],label_sensorValue); sensorreading = Int32.Parse(tokens[0]); sensordistance = (mathfunctionhere); Great. So the further away the IR sensor is from an object, the lower the sensor reading (as less light is reflected back and received by the sensor). My problem is in interpreting that length. I can go ahead and get lets say "110" as a value when an object is 5 inches away, and then "70" as a value when an object is 6 inches away. Now I want to be able to calculate the distance of an object using these constants for any length. Any ideas?

    Read the article

  • What is the worst class/variable/function name you have ever encountered

    - by Chris Noe
    Naming things well is arguably Job 1 for professional programmers. Yet we have all suffered from some bad naming choices from time to time. So just to vent a little, what are some doozies that you may have run across? Just to get things started: One of our original developers wasn't sure what to call a secondary key - on what turned out to be a primary table for this app - so he called it: DL2WhateverTheHellThatIs. Unfortunately this system generates entity mappings from the XML, and attributes defined there result in classes, methods, and constants that are referenced through-out the app. To this day it is very hard to find a source file that does not reference this, er, thing! A few actual examples: DL2WhateverTheHellThatIsBean cos = (DL2WhateverTheHellThatIsBean)itr.next(); String code = getDL2WhateverTheHellThatIs().getCode(); From from = new From("DL2WhateverTheHellThatIs"); String filter = "_dL2WhateverTheHellThatIs._code"; (Very difficult to refactor)

    Read the article

  • getItemIdAtPosition() problem in Android?

    - by Praveen Chandrasekaran
    I am using the getItemIdAtPosition() to get the Basecoulmns id of the record in Sqlite Database. the code is below: protected void onListItemClick(ListView l, View v, int position, long id) { Cursor cursor = managedQuery(Constants.CONTENT_URI, PROJECTION, BaseColumns._ID + "=" + l.getItemIdAtPosition(position), null, null); } But its does not retrieves the id correctly. Is this method depends some thing at the time of setting adapter or creation of DB? I have no idea. why it shows the position of the listview. Any Idea?

    Read the article

  • Strategy for developing namespaced and non-namespaced versions of same PHP code

    - by porneL
    I'm maintaining library written for PHP 5.2 and I'd like to create PHP 5.3-namespaced version of it. However, I'd also keep non-namespaced version up to date until PHP 5.3 becomes so old, that even Debian stable ships it ;) I've got rather clean code, about 80 classes following Project_Directory_Filename naming scheme (I'd change them to \Project\Directory\Filename of course) and only few functions and constants (also prefixed with project name). Question is: what's the best way to develop namespaced and non-namespaced versions in parallel? Should I just create fork in repository and keep merging changes between branches? Are there cases where backslash-sprinkled code becomes hard to merge? Should I write script that converts 5.2 version to 5.3 or vice-versa? Should I use PHP tokenizer? sed? C preprocessor? Is there a better way to use namespaces where available and keep backwards compatibility with older PHP?

    Read the article

  • The best way to assign an immutable instance to a Collection in Java

    - by Ali
    Today I was reading through some Hibernate code and I encounter something interesting. There is a class called CollectionHelper that defines the following constant varibale: public final class CollectionHelper { public static final List EMPTY_LIST = Collections.unmodifiableList( new ArrayList(0 ) ; public static final Collection EMPTY_COLLECTION = Collections.unmodifiableCollection(new ArrayList(0) ); public static final Map EMPTY_MAP = Collections.unmodifiableMap( new HashMap(0) ); They have used these constants to initialize collections with immutable instances. Why they didn't simply use the Collections.EMPTY_LIST for initializing lists? Is there a benefit in using the following method?

    Read the article

  • Calling a C function in a DLL with enum parameters from Delphi

    - by dommer
    I have a third-party (Win32) DLL, written in C, that exposes the following interface: DLL_EXPORT typedef enum { DEVICE_PCI = 1, DEVICE_USB = 2 } DeviceType; DLL_EXPORT int DeviceStatus(DeviceType kind); I wish to call it from Delphi. How do I get access to the DeviceType constants in my Delphi code? Or, if I should just use the values 1 and 2 directly, what Delphi type should I use for the "DeviceType kind" parameters? Integer? Word?

    Read the article

  • Objective-C Custom extend

    - by ryanjm.mp
    I have a couple classes that have nearly identical code. Only a string or two is different between them. What I would like to do is to make them from another class that defines those functions and then uses constants or something else to define those strings that are different. I'm not sure if "___" is inheritance or extending or what. That is what I need help with. For example: objectA.m: -(void)helloWorld { NSLog("Hello %@",child.name); } objectBob.m: #define name @"Bob" objectJoe.m #define name @"Joe" (I'm not sure if it's legal to define strings, but this gets the point across) It would be ideal if objectBob.m and objectJoe.m didn't have to even define the methods, just their relationship to objectA.m. Is there any way to do something like this? If all else fails I'll just make objectA.m: -(void)helloWorld:(NSString *name) { NSLog("Hello %@",name); } And have the other files call that function (and just #import objectA.m).

    Read the article

  • LINQ and paging with a DataTable - can't get Skip working?

    - by Kit Menke
    Ok so this might be a dumb question, but I can't seem to figure it out. I thought I'd try out LINQ against a DataTable. I got my query working and now I'm trying to implement some simple paging. DataTable dataTable = null; dataTable = GetAllDataTables(); var query = from r in dataTable.AsEnumerable() orderby r.Field<string>(Constants.fileName) select r; query.Skip(WPP_PAGE_SIZE * pageIndex).Take(WPP_PAGE_SIZE); My problem is that I get an error at query.Skip(...). Error 1 'System.Data.OrderedEnumerableRowCollection' does not contain a definition for 'Skip' and no extension method 'Skip' accepting a first argument of type 'System.Data.OrderedEnumerableRowCollection' could be found (are you missing a using directive or an assembly reference?) References I have: Microsoft.SharePoint System System.Core System.Data System.Data.DataSetExtensions System.Web System.Xml What am I missing?

    Read the article

  • C Preprocessor: #define in C... advice

    - by vikramtheone
    Hi Guys, I'm making a big C project and I have never come across a situation like this before so, I need your advice. What is your opinion? Is it okay to have the constants defined within conditional preprocessors like I have done below or you advise me to do this some other way? Any drawbacks if I do it this way? Regards Vikram #define NUM_OCTAVES_4 //#define NUM_OCTAVES_5 #ifdef NUM_OCTAVES_4 #define OCTAVES 4 const unsigned char borders [4] = {11, 26, 50, 98}; #elif NUM_OCTAVES_5 #define OCTAVES 5 const unsigned char borders [5] = {11, 26, 50, 98, 194}; #endif

    Read the article

  • Which class for making many replacements

    - by HCL
    I have to make a lot of text-replacements. Which class is best used to make this in a performant manner. Is it StringBuilder? StringBuilder stringBuilder=new StringBuilder(startString); stringBuilder.Replace(literala1,literala2); stringBuilder.Replace(literalb1,literalb2); stringBuilder.Replace(literalc1,literalc2); ... or does exists a better class to do this. Btw, the literals will be mostly constants.

    Read the article

  • Problem getting CodeIgniter working with WAMP

    - by musoNic80
    I've been developing a project based on CodeIgniter on my MacBook Pro. For reasons I don't need to go into I've now had to move my work onto a PC running Windows XP. I've installed WAMP and brought my existing project into the www folder. Unfortunately, when I try and access the project via localhost it throws up include errors. It seems that for some reason the constants APPPATH and BASEPATH seem to be incorrect. I've checked the index.php file and it all seems ok. I've also downloaded a fresh version of CodeIgniter and placed that in my www folder. I can access the welcome message without any problems. Any ideas?

    Read the article

  • Problem with Clojure function

    - by Bozhidar Batsov
    Hi, everyone, I've started working yesterday on the Euler Project in Clojure and I have a problem with one of my solutions I cannot figure out. I have this function: (defn find-max-palindrom-in-range [beg end] (reduce max (loop [n beg result []] (if (>= n end) result (recur (inc n) (concat result (filter #(is-palindrom? %) (map #(* n %) (range beg end))))))))) I try to run it like this: (find-max-palindrom-in-range 100 1000) and I get this exception: java.lang.Integer cannot be cast to clojure.lang.IFn [Thrown class java.lang.ClassCastException] which I presume means that at some place I'm trying to evaluate an Integer as a function. I however cannot find this place and what puzzles me more is that everything works if I simply evaluate it like this: (reduce max (loop [n 100 result []] (if (>= n 1000) result (recur (inc n) (concat result (filter #(is-palindrom? %) (map #(* n %) (range 100 1000)))))))) (I've just stripped down the function definition and replaced the parameters with constants) Thanks in advance for your help and sorry that I probably bother you with idiotic mistake on my part. Btw I'm using Clojure 1.1 and the newest SLIME from ELPA.

    Read the article

  • How to find GTK version in PHP-GTK2?

    - by aidave
    This one is driving me nuts. According to GTK's site, there exists GTK_MAJOR_VERSION, GTK_MINOR_VERSION, and GTK_MICRO_VERSION constants. However, none of these work: echo GTK_MAJOR_VERSION; echo GtK::MAJOR_VERISON; echo Gtk::GTK_MAJOR_VERSION; etc Also, Gtk::check_version(2,12,0) always fails even though I have a higher version. I'd like to simply get the actual version number and not rely on check_version, which seems unreliable. How can I do this? I need to do it within PHP, platform independent.

    Read the article

  • How do I compile for windows XP under windows 7 / visual studio 2008

    - by Jon Cage
    I'm running Windows 7 and Visual Studio 2008 Pro and trying to get my application to work on Windows XP SP3. It's a really minimal command line program so should have any ridiculous dependencies: // XPBuild.cpp : Defines the entry point for the console application. // #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { printf("Hello world"); getchar(); return 0; } I read somewhere that defining several constants such as WINVER should allow me to compile for other platforms. I've tried the added the following to my /D compiler options: ;WINVER=0x0501;_WIN32_WINNT 0x0501;NTDDI_VERSION=NTDDI_WINXP But that made no difference. When I run it on my Windows XP machine (actually running in a virtualbox) I get the following error: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. So what have I missed? Is there something else required to run MSVC compiled programs or a different compiler option or something else?

    Read the article

  • Multiplying complex with constant in C++

    - by Atilla Filiz
    The following code fails to compile #include <iostream> #include <cmath> #include <complex> using namespace std; int main(void) { const double b=3; complex <double> i(0, 1), comp; comp = b*i; comp=3*i; return 0; } with error: no match for ‘operator*’ in ‘3 * i’ What is wrong here, why cannot I multiply with immediate constants?

    Read the article

  • Long IF tree with strings

    - by DalGr
    I have a C program which uses Lua for scripting. In order to keep readability and avoid importing several constants within the individual Lua states, I condense a large amount of functions within a simple call (such as "ObjectSet(id, "ANGLE", 45)"), by using an "action" string. To do this I have a large if tree comparing the action string to a list (such as "if(stringcompare(action, "ANGLE") ... else if (stringcompare(action, "X")... etc") This approach works well, and within the program it's not really slow, and is fairly quick to add a new action. But I kind of feel perfectionist. Is there a better way to do this in C? And having Lua in heavy use, maybe there is a way to use it for this purpose? (embedded "chunks" making a dictionary?) Although this part is mostly curiosity.

    Read the article

  • How do I programmatically set property of control in aspx file ?

    - by Thomas Wanner
    This may be a very dumb question but I can't seem to get it working. I use at many places the following syntax for dynamically binding a property of a control in aspx file to the resource entry, e.g. <SomeFunnyControl Text="<%$ Resources : ResClass, ResEntry %>" /> I want to do a similar thing with a class containing some constants, something like <SomeFunnyControl Text="<%= MyConstantsClass.MyStringConstant %>" /> But this doesn't seem to work, it simply sets the text to the exact expression without evaluating it. I am using ASP.NET 3.5 btw. I have tried the databinding approach but I get an HttpParseException saying Databinding expressions are only supported on objects that have a DataBinding event.

    Read the article

  • Scoping in embedded groovy scripts

    - by Aaron Digulla
    In my app, I use Groovy as a scripting language. To make things easier for my customers, I have a global scope where I define helper classes and constants. Currently, I need to run the script (which builds the global scope) every time a user script is executed: context = setupGroovy(); runScript( context, "global.groovy" ); // Can I avoid doing this step every time? runScript( context, "user.groovy" ); Is there a way to setup this global scope once and just tell the embedded script interpreter: "Look here if you can't find a variable"? That way, I could run the global script once. Note: Security is not an issue here but if you know a way to make sure the user can't modify the global scope, that's an additional plus.

    Read the article

  • What is Ruby's double-colon (::) all about?

    - by Meltemi
    I'd probably be able to answer this for myself if "::" wasn't so hard to Google. Didn't see anything on SO so thought I'd try my luck. What is this double-colon :: all about? I see it everywhere in Rails: class User < ActiveRecord::Base or… ActionController::Routing::Routes.draw do |map| I found a definition from this guy: The :: is a unary operator that allows: constants, instance methods and class methods defined within a class or module, to be accessed from anywhere outside the class or module. but that just leads to more questions. What good is scope (private, protected) if you can just use :: to expose anything?

    Read the article

  • Need help for this syntax: "#define LEDs (char *) 0x0003010"

    - by Noge
    I'm doing programming of a softcore processor, Nios II from Altera, below is the code in one of the tutorial, I manage to get the code working by testing it on the hardware (DE2 board), however, I could not understand the code. #define Switches (volatile char *) 0x0003000 #define LEDs (char *) 0x0003010 void main() { while (1) *LEDs = *Switches; } What I know about #define is that, it is either used to define a constant, or a macro, but why in the above code, there are casting like, (char *) 0x0003010, in #define? why the 2 constants, Switches and LEDs act like a variable instead of a constant? Thanks in advance !

    Read the article

  • Error handling and polymorphism

    - by Neeraj
    I have an application with some bunch of code like this: errCode = callMainSystem(); switch (errCode){ case FailErr: error("Err corresponding to val1\n"); case IgnoreErr: error("Err corresponding to val2\n"); ... ... default: error("Unknown error\n"); } The values are enum constants. Will it make some sense to have something like: // Error* callMainSystem() ... Some code return FaileErr(); // or some other error // handling code Error* err = callMainSystem(); err->toString(); The Error class may be made singleton as it only has to print error messages. What are the pros and cons of above methods,size is an important criteria as the application needs to be supported on embedded devices as well. P.S: I don't want to use exception handling because of portability issues and associated overheads.

    Read the article

  • Can Somebody Explain this java code

    - by dubbeat
    Hi, I'm just starting out on android and my java is verry rusty. I can't remember ever seeing a function nested in another function like this before. Could somebody explain to me exactly what final does and explain why you would nest a function in another like this? private final Handler handler = new Handler() { @Override public void handleMessage(final Message msg) { Log.v(Constants.LOGTAG, " " + ReviewList.CLASSTAG + " worker thread done, setup ReviewAdapter"); progressDialog.dismiss(); if ((reviews == null) || (reviews.size() == 0)) { empty.setText("No Data"); } else { reviewAdapter = new ReviewAdapter(ReviewList.this, reviews); setListAdapter(reviewAdapter); } } };

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >