473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

where to put #define

Hi,

If I put a #define somewhere in a file then the compiler complains with
'cannot define/undefine after first token in file'

So I plase #define in very begin of file, but then compiler say 'single line
comment or end of line expected'.

Now what ?
The second error does really not give me a hint on what is wrong :( What is ?

Or is #defoine in C# different ? eg I do this:
#define test 1
#define TEST

--
rgds, Wilfried
http://www.mestdagh.biz
Nov 17 '05 #1
2 4305
Unfortunately only your second define is valid in C# where
the #define defines a symbol that can be used with things
like #if and other precompiler directives.

Take a look at
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/csref/html/vclrfdefine.asp for a bit
more info.

Suffice to say, in C# you cannot #define a variable the
way you could in c or c++.
-----Original Message-----
Hi,

If I put a #define somewhere in a file then the compiler complains with'cannot define/undefine after first token in file'

So I plase #define in very begin of file, but then compiler say 'single linecomment or end of line expected'.

Now what ?
The second error does really not give me a hint on what is wrong :( What is ?
Or is #defoine in C# different ? eg I do this:
#define test 1
#define TEST

--
rgds, Wilfried
http://www.mestdagh.biz
.

Nov 17 '05 #2
Unfortunately only your second define is valid in C# where
the #define defines a symbol that can be used with things
like #if and other precompiler directives.

Take a look at
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/csref/html/vclrfdefine.asp for a bit
more info.

Suffice to say, in C# you cannot #define a variable the
way you could in c or c++.
-----Original Message-----
Hi,

If I put a #define somewhere in a file then the compiler complains with'cannot define/undefine after first token in file'

So I plase #define in very begin of file, but then compiler say 'single linecomment or end of line expected'.

Now what ?
The second error does really not give me a hint on what is wrong :( What is ?
Or is #defoine in C# different ? eg I do this:
#define test 1
#define TEST

--
rgds, Wilfried
http://www.mestdagh.biz
.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mayer Goldberg | last post by:
Can someone please explain the motivation behind the following restriction in the language: I define an interface and two classes implementing it: public interface InterA {} public class B...
2
by: cppaddict | last post by:
Hi, The question of where to define operator< came up when I was using the std::sort method. Let's say I have a container whose members (of class A) I need to sort. In particular, we have some...
1
by: Ips | last post by:
hello! Where can I find a reference to the information that the define names starting with unserscores are reserved for compilers? I mean something like this: #define __MYFILE__ "test.h" or...
3
by: wende | last post by:
1. #define MA \ .... { i = j; } .... 2
10
by: Brett | last post by:
If I have many hard coded values such as file paths, file names, timeouts, etc, where is the best place to define them? Meaning, in the case something needs changing for example, rather than...
40
by: Spiros Bousbouras | last post by:
Do you have an example of an implementation where sizeof(short int) does not divide sizeof(int) or sizeof(int) does not divide sizeof(long int) or sizeof(long int) does not divide sizeof(long long...
34
by: linq936 | last post by:
Hi, I just did the following test: 1:void main(void){ 2: int p = 1; 3: int* pp = &p; 4: int c = p * pp; 5: int d = p + pp; 6:}
9
by: anon.asdf | last post by:
Hi! The following code is a snippet where the goto's cannot be removed "without increasing code-size, or decreasing performance". /*********A**************/ int var_other_thread; // value...
2
by: Tark Siala | last post by:
hi i worked with VB6 then i changed to C#. i want define Variable thats i can accessed from any Form or Class in my project. in VB6 you can do that by define as "Global" in Module, but in C# i...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.