473,395 Members | 1,702 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,395 software developers and data experts.

how to solve this #define issue?

Anyone have a clean way of solving this define issue?

In Windows, there are sometimes unicode functions and multibyte functions...
the naming convention used is FunctionA for multibyte and FunctionW for
unicode...

So basically what happens is:

void FunctionA();
void FunctionW();

#ifdef _UNICODE
#define Function FunctionW
#else
#define Function FunctionA
#endif

now I have a class...

class Whatever
{
public:
void Function();
};

obviously this gets mapped to either FunctionA or FunctionW, which I dont
want...

I want *my* function to be called "Function", but be able to call FunctionA
or FunctionW with in my code...

Also if someone calls my library, to be able to call "Function" without
loosing the ability of the Windows "Function" macro...

Is there any way to solve this cleanly without undefing "Function" for the
whole project?

I can't even rename my "Function" to anything close without totally going
"stupid" like "Funktion".

Jul 4 '06 #1
7 2137
* Nobody:
Anyone have a clean way of solving this define issue?

In Windows, there are sometimes unicode functions and multibyte functions...
the naming convention used is FunctionA for multibyte and FunctionW for
unicode...

So basically what happens is:

void FunctionA();
void FunctionW();

#ifdef _UNICODE
#define Function FunctionW
#else
#define Function FunctionA
#endif

now I have a class...

class Whatever
{
public:
void Function();
};

obviously this gets mapped to either FunctionA or FunctionW, which I dont
want...

I want *my* function to be called "Function", but be able to call FunctionA
or FunctionW with in my code...

Also if someone calls my library, to be able to call "Function" without
loosing the ability of the Windows "Function" macro...

Is there any way to solve this cleanly without undefing "Function" for the
whole project?

I can't even rename my "Function" to anything close without totally going
"stupid" like "Funktion".
Naming convention. Call your function "function", not "Function".

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 4 '06 #2
mos
Hi!

Just copy the windows's define before your class. thus:

//class Whatever.h

#ifdef _UNICODE
#define Function FunctionW
#else
#define Function FunctionA
#endif

class Whatever
{
public:
void Function();
};

"Nobody" <no****@cox.netдÈëÏûÏ¢ÐÂÎÅ:JTmqg.24334$8q.7462@du keread08...
Anyone have a clean way of solving this define issue?

In Windows, there are sometimes unicode functions and multibyte
functions... the naming convention used is FunctionA for multibyte and
FunctionW for unicode...

So basically what happens is:

void FunctionA();
void FunctionW();

#ifdef _UNICODE
#define Function FunctionW
#else
#define Function FunctionA
#endif

now I have a class...

class Whatever
{
public:
void Function();
};

obviously this gets mapped to either FunctionA or FunctionW, which I dont
want...

I want *my* function to be called "Function", but be able to call
FunctionA or FunctionW with in my code...

Also if someone calls my library, to be able to call "Function" without
loosing the ability of the Windows "Function" macro...

Is there any way to solve this cleanly without undefing "Function" for the
whole project?

I can't even rename my "Function" to anything close without totally going
"stupid" like "Funktion".

Jul 4 '06 #3
In article <JTmqg.24334$8q.7462@dukeread08>, no****@cox.net says...

[ ... ]
#ifdef _UNICODE
#define Function FunctionW
#else
#define Function FunctionA
#endif
[ ... ]
I want *my* function to be called "Function", but be able to call FunctionA
or FunctionW with in my code...
I don't know whether you consider it very clean or not, but if you
enclose its name in parentheses, the name won't be expanded as a
macro:

(Function)(args); // calls your Function
Function(args); // calls their FunctionA or FunctionW

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 4 '06 #4
* Jerry Coffin:
In article <JTmqg.24334$8q.7462@dukeread08>, no****@cox.net says...

[ ... ]
>#ifdef _UNICODE
#define Function FunctionW
#else
#define Function FunctionA
#endif

[ ... ]
>I want *my* function to be called "Function", but be able to call FunctionA
or FunctionW with in my code...

I don't know whether you consider it very clean or not, but if you
enclose its name in parentheses, the name won't be expanded as a
macro:

(Function)(args); // calls your Function
Function(args); // calls their FunctionA or FunctionW
The following program,

#define FOO foo

void foo() {}

int main()
{
FOO();
(FOO)();
}

compiles fine with a number of compilers, including Comeau Online.

Hence, I wonder if you have standard chapter-&-verse id's?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 4 '06 #5
In article <4g*************@individual.net>, al***@start.no says...

[ ... ]
The following program,

#define FOO foo

void foo() {}

int main()
{
FOO();
(FOO)();
}

compiles fine with a number of compilers, including Comeau Online.

Hence, I wonder if you have standard chapter-&-verse id's?
Thinking about it, what I said doesn't apply in this case.

In the case of a function-like macro, the name must be followed
immediately by a left-paren to be expanded as a macro. Unfortunately,
even though they're names of functions, they're using object-like
macros instead of function-like macros in this case.

So, for the trick I cited to work, you'd have to do the defines
something like:

#ifdef UNICODE
#define Function(x) FunctionW(x)
#else
#define Function(x) FunctionA(x)
#endif

As far as chapter and verse, 16.3/9 is what applies (in the correct
situation).

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 4 '06 #6
the other way might be to provide concrete implementation for
FunctionA()
& FunctionW()

Now on calling fuction() from your application code, it will call the
exact function based on your application project setting.

-Amit

Jerry Coffin wrote:
In article <4g*************@individual.net>, al***@start.no says...

[ ... ]
The following program,

#define FOO foo

void foo() {}

int main()
{
FOO();
(FOO)();
}

compiles fine with a number of compilers, including Comeau Online.

Hence, I wonder if you have standard chapter-&-verse id's?

Thinking about it, what I said doesn't apply in this case.

In the case of a function-like macro, the name must be followed
immediately by a left-paren to be expanded as a macro. Unfortunately,
even though they're names of functions, they're using object-like
macros instead of function-like macros in this case.

So, for the trick I cited to work, you'd have to do the defines
something like:

#ifdef UNICODE
#define Function(x) FunctionW(x)
#else
#define Function(x) FunctionA(x)
#endif

As far as chapter and verse, 16.3/9 is what applies (in the correct
situation).

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 4 '06 #7

"Nobody" <no****@cox.netwrote in message
news:JTmqg.24334$8q.7462@dukeread08...
Anyone have a clean way of solving this define issue?

In Windows, there are sometimes unicode functions and multibyte
functions... the naming convention used is FunctionA for multibyte and
FunctionW for unicode...

So basically what happens is:

void FunctionA();
void FunctionW();

#ifdef _UNICODE
#define Function FunctionW
#else
#define Function FunctionA
#endif

now I have a class...

class Whatever
{
public:
void Function();
};
class Whatever
{
public:
#undefine Function
void Function();
#ifdef _UNICODE
#define Function FunctionW
#else
#define Function FunctionA
#endif
};


>
obviously this gets mapped to either FunctionA or FunctionW, which I dont
want...

I want *my* function to be called "Function", but be able to call
FunctionA or FunctionW with in my code...

Also if someone calls my library, to be able to call "Function" without
loosing the ability of the Windows "Function" macro...

Is there any way to solve this cleanly without undefing "Function" for the
whole project?

I can't even rename my "Function" to anything close without totally going
"stupid" like "Funktion".

Jul 4 '06 #8

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

Similar topics

14
by: Carl Ribbegaardh | last post by:
What other c++ constructs can I use instead of #define for executing a couple of functions? Example: #define DO_STUFF doThis(); doThat(); I'd guess that I can either use a template function,...
3
by: Alex | last post by:
Hi, I have a problem involving some design issue. I have two unrelated (that is, they do not derive from the same base) classes: ClassA ClassB Both have a quite similar interface, so they can...
34
by: BQ | last post by:
Hello Is there a way to declare 'FUNCT' via a define so that if its parameter x, a constant, is greater than 35, it returns 56, if not, 20. I would like that at compile time, not at run time. ...
9
by: claymic | last post by:
I am trying to complete some math tutorials, and wanted to write an answer generator in C. The type of question is; "A doll costs $20, a toy car costs $6, a yoyo costs $1. What combination of...
7
by: hierro | last post by:
I have a list of functions (all with suffix T). For each one, I need to implement the following: FunctionT() { if (some_condition) { // do some conversion first FunctionW(); // then do some...
7
by: No Spam | last post by:
----snip #define POSITIVE_INTEGRATOR_SATURATION 0x03000000L // #define NEGATIVE_INTEGRATOR_SATURATION 0xFD000000L // long integrator; integrator=0;
7
by: Shapper | last post by:
Hello, I have an ASP:ImageButton where I want to call a function and pass a string: OnClick="Change_Photo("John")" I am having problems with "". I tried
16
by: Hooyoo | last post by:
Following are similar codes of my project: At first I define two classes in two files: //ClassA.h #pragma once #include "ClassB.h" class ClassA { public: ClassA(void){};
3
by: thalinx | last post by:
Hi can ayone help me with this program, cause i dont know how to solve the compiling errors here. thanks # include<stdlib.h> # include<conio.h> # include<stdio.h> # define MAXCADENA 8 # define...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.