define

Different ways to declare/define variables?

Hello This is a VB.Net newbie question. I'm confused at the different ways to declare and define variables. Here's an example: Dim URL As String = http://www.c-sharpcorner.com/default.asp Dim request As HttpWebRequest = WebRequest.Create(URL) Dim response As HttpWebResponse = request.GetResponse() Dim reader As StreamReader = New Stre...

Python: ball isn't defined

I get this error: Traceback (most recent call last): File "D:/Python26/PYTHON-PROGRAMME/049 bam", line 9, in <module> ball[i][j]=sphere() NameError: name 'ball' is not defined when I run this code. But the ball is defined ( ball[i][j]=sphere() ). Isn`t it? #2D-wave #VPython from visual import * #ball array #ready for i in ran...

Shall I prefer constants over defines?

In C, shall I prefer constants over defines? I've reading a lot of code lately, and all of the examples make heavy use of defines. ...

How to use C macro's (#define) to alter calls but not prototypes

In our application (older parts) we alter calls to malloc (and realloc) and free so our own implementations are called instead of the standard runtime ones, e.g. #define malloc(s) OurMalloc(s) #define free(p) OurFree(p) This works quite good (for newer C++ code we simply implement global new and delete operators, so the C++ solution...

how to compare string in C conditional preprocessor-directives

i have to do something like this in C but it works only if I use a char but I need a string how can I do? #define USER "jack" // jack or queen #if USER == "jack" #define USER_VS "queen" #elif USER == "queen" #define USER_VS "jack" #endif thanks to all! ...

C# equivalent of the Ruby symbol.

Hi, I'm developing a little C# application for the fun. I love this language but something disturb me ... Is there any way to do a #define (C mode) or a symbol (ruby mode). The ruby symbol is quite useful. It's just some name preceded by a ":" (example ":guy") every symbol is unique and can be use any where in the code. In my case i'...

C Macro for minimum of two numbers

I want to make a simple macro with #define for returning the smaller of two numbers. How can i do this in C ? Suggest some ideas, and see if you can make it more obfuscated too. ...

How to definie a VB.NET DataTable Column as primary key after creation

Hello I am importing Tables from a Oracle DataBase, using a VB.NET dataAdapter. I use the "fill" comand to add the imported data to a DataSet. How is it possible to define a specific column of a DataTable as PrimaryKey, after the DataTable is already filled with data? Thank your for your help. ...

Where is core animation defined?

I cant figure out where core animation on iPhone OS 3.1.2 is defined. Anybody know? ...

for loop in #define

#include <stdio.h> #define UNITS {'*', '#', '%', '!', '+', '$', '=', '-'} #define PrintDigit(c, d) (for (i=0; i < c ; i++)putchar(unit[d]);) char unit[] = UNITS; //void PrintDigit(c, element) { // int i; // for (i=0; i < c ; i++) // putchar(unit[element]); //} int main( ) { int i, element=4; PrintDigit(10, element); ...

#define and how to use them - C++

Hi All, in a pre-compiled header if I do: #define DS_BUILD #define PGE_BUILD #define DEMO then in source I do: #if (DS_BUILD && DEMO) ---- code--- #elif (PGE_BUILD && DEMO) --- code--- #else --- code --- #endif Do I get an error that states: error: operator '&&' has no right operand I have never seen this before. I am...

How to process all #include directives in Visual Studio C++ 2005?

Hi, I want to see how my #include files be processed when Microsoft Visual Studio C++ compile it. As I remember, there is a compile option to inline all #includes and #define lines but I can't find it. I use MSVC 2005 sp1. Thanks. ...

static, define, and const in C

Hi, I've read that static variables are used inside function when one doesn't want the variable value to change/initialize each time the function is called. But what about defining a variable static in the main program before "main" e.g. #include <stdio.h> static double m = 30000; int main(void) { value = m * 2 + 3; } Here the varia...

CruiseControl.NET Preprocessor 'include' Anomaly

Here's a strange one relating to a combination of the 'define' and 'include' functionality that the CC.NET preprocessor exposes. We're running CCNet 1.4.4.83, and our ccnet.config file is structured and split to make best use of common element blocks stored in subfiles that are included by the main config file; we also split out the core...

#Define's scope throughout library?

Say I have a constant: #define PI 3.14 Say I have a static library with multiple header and source files. If I declare this in the header file, will its scope apply to all of the source files? Or do the source files need to include the header with the declaration of PI? ...

Possible to convert list of #defines into strings (C++)

Suppose I have a list of #defines in a header file for an external library. These #defines represent error codes returned from functions. I want to write a conversion function that can take as an input an error code and return as an output a string literal representing the actual #define name. As an example, if I have #define NO_ERROR ...

value of c define changes unexpectedly

I have a lot of #define's in my code. Now a weird problem has crept up. I have this: #define _ImmSign 010100 (I'm trying to simulate a binary number) Obviously, I expect the number to become 10100. But when I use the number it has changed into 4160. What is happening here? And how do I stop it? ADDITIONAL Okay, so this is due ...

Macros in macros (C++)

Is it possible to put a macro in a macro in c++? Something like: #define Something\ #ifdef SomethingElse\ //do stuff \ #endif\ I tried and it didn't work so my guess is it doesn't work, unless there's some sort of syntax that can fix it? ...

Initializing PHP class property declarations with simple expressions yields syntax error

According to the PHP docs, one can initialize properties in classes with the following restriction: "This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated." I'm trying...

wonder about some #define tricks

Whlie reading codes of my group project, I come across many DEFINEs, and some of them seems strange. To generalize it, please look at the following 2 examples. Example 1: #define SNPRINTF(dst, fmt, arg...) snprintf(dst, sizeof(dst), fmt, ##arg) what does "##" means in this circumstance? I've tried to delete both of them, and wri...