472,973 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,973 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 2110
* 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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.