#ifdef上出现RC2104错误 [英] RC2104 error on #ifdef

查看:106
本文介绍了#ifdef上出现RC2104错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

在C ++ MFC应用程序中,我需要有条件地#include我的主资源文件中另外两个

资源文件中的一个,因为不同的表单

应用程序有不同的名称。我还想使用IDE的资源编辑器编辑主资源

文件并保存它而不会丢失条件

#includes特定于名称的资源文件。所以,主资源文件

包括以下内容:


3 TEXTINCLUDE

BEGIN

" ; #include"" apptype.h""

" #ifdef APP_A" //< ---- error

" #include"" app_a.rc""

"#else"

" #include"" app_b.rc""

" #endif"

//其他#includes

" \0"

END


但是,RC在标记的行上产生RC2104错误,并带有消息

未定义的关键字或密钥名称:#ifdef。由于RC通常理解#ifdef我

不明白为什么它抱怨TEXTINCLUDE中的一个。可以有人

解释一下吗?


在同一主题上,这是一个MDI应用程序,每个菜单都有一个菜单

不同的文件类型。我不得不将_all_菜单放在

app-name特定的资源文件中,而这只是因为About ...项目

在帮助菜单上(按照惯例,此项目包括应用程序名称:

"关于AppA ...或关于AppB .. ")。这意味着任何菜单更改必须在两个资源文件中完成。有没有更简单的方法呢?


我使用的是VS .NET 2003.


David

Hello,

In a C++ MFC application I need to conditionally #include one of two additional
resource files in my main resource file because different forms of the
application have different names. I would also like to edit the main resource
file with the IDE''s resource editor and save it without losing the conditional
#includes of the name-specific resource files. So, the main resource file
includes the following:

3 TEXTINCLUDE
BEGIN
"#include ""apptype.h""
"#ifdef APP_A" // <---- error
"#include ""app_a.rc""
"#else"
"#include ""app_b.rc""
"#endif"
// the other #includes
"\0"
END

However, RC is producing an RC2104 error on the marked line with the message
"Undefined keyword or key name: #ifdef". Since RC normally understands #ifdef I
don''t understand why it complains about one in a TEXTINCLUDE. Can someone
explain it?

On the same subject, this is an MDI application with one menu for each of many
different document types. I have had to put _all_ menus in both
app-name-specific resource files, and it''s only because of the "About..." item
on the Help menu (since, by convention, this item includes the application name:
"About AppA..." or "About AppB..."). This means that any menu changes must be
done in both resource files. Is there an easier way to do this?

I am using VS .NET 2003.

David

推荐答案

David W写道:
David W wrote:

你好,


在C ++中MFC应用程序我需要在我的主资源文件中有条件地#include两个额外的

资源文件之一,因为不同形式的

应用程序有不同的名称。我还想使用IDE的资源编辑器编辑主资源

文件并保存它而不会丢失条件

#includes特定于名称的资源文件。所以,主资源文件

包括以下内容:


3 TEXTINCLUDE

BEGIN

" ; #include"" apptype.h""

" #ifdef APP_A" //< ---- error

" #include"" app_a.rc""

"#else"

" #include"" app_b.rc""

" #endif"

//其他#includes

" \0"

END


但是,RC在标记的行上产生RC2104错误,并带有消息

未定义的关键字或密钥名称:#ifdef。由于RC通常理解#ifdef我

不明白为什么它抱怨TEXTINCLUDE中的一个。可以有人

解释一下吗?


在同一主题上,这是一个MDI应用程序,每个菜单都有一个菜单

不同的文件类型。我不得不将_all_菜单放在

app-name特定的资源文件中,而这只是因为About ...项目

在帮助菜单上(按照惯例,此项目包括应用程序名称:

"关于AppA ...或关于AppB .. ")。这意味着任何菜单更改必须在两个资源文件中完成。有更简单的方法吗?
Hello,

In a C++ MFC application I need to conditionally #include one of two additional
resource files in my main resource file because different forms of the
application have different names. I would also like to edit the main resource
file with the IDE''s resource editor and save it without losing the conditional
#includes of the name-specific resource files. So, the main resource file
includes the following:

3 TEXTINCLUDE
BEGIN
"#include ""apptype.h""
"#ifdef APP_A" // <---- error
"#include ""app_a.rc""
"#else"
"#include ""app_b.rc""
"#endif"
// the other #includes
"\0"
END

However, RC is producing an RC2104 error on the marked line with the message
"Undefined keyword or key name: #ifdef". Since RC normally understands #ifdef I
don''t understand why it complains about one in a TEXTINCLUDE. Can someone
explain it?

On the same subject, this is an MDI application with one menu for each of many
different document types. I have had to put _all_ menus in both
app-name-specific resource files, and it''s only because of the "About..." item
on the Help menu (since, by convention, this item includes the application name:
"About AppA..." or "About AppB..."). This means that any menu changes must be
done in both resource files. Is there an easier way to do this?



David:


不太确定我明白你想要什么,但如果有什么不能的话

可以通过资源

编辑器的条件编译功能完成,然后我将材料移动到.rc2文件中,你可以在这里放置

#ifdef'的如你所愿,而不会破坏资源编辑器。在我的情况下

这只是几个字符串。


至于关于框,在OnInitDialog中编写代码很容易

修改文本。使用AFX_IDS_APP_TITLE来获取应用程序标题(这是我在.rc2文件中输入的一个字符串
)。


David Wilkinson

David:

Not quite sure I understand what you want here, but if something cannot
be accomplished by the conditional compilation feature of the resource
editor, then I move the material into the .rc2 file, where you can put
#ifdef''s as you desire without upsetting the resource editor. In my case
this is just a few strings.

As to the About box, it is easy enough to write code in OnInitDialog to
modify the text. Use AFX_IDS_APP_TITLE to get the app title (this is one
of the strings that I put in the .rc2 file).

David Wilkinson


您好,


您可以尝试在每行的末尾添加\\\\ n,如下所示:


3 TEXTINCLUDE

BEGIN

" #include"" apptype.h" \\ nn"

" #ifdef APP_A \\ n 

....


就像我自动生成的那样。 rc文件。也许在你的例子中,他'

连接同一行上的2个字符串,这可以解释错误。


Wim


" David W"写道:
Hi,

Can you try adding \r\n at the end of each line like this:

3 TEXTINCLUDE
BEGIN
"#include ""apptype.h"\r\n"
"#ifdef APP_A\r\n"
....

It''s like that in my auto-generated .rc files. Maybe in your example he''s
concatenating the 2 strings on the same line, which would explain the error.

Wim

"David W" wrote:

您好,


在C ++ MFC应用程序中,我需要有条件地#include两个附加中的一个

我的主资源文件中的资源文件,因为

应用程序的不同形式有不同的名称。我还想使用IDE的资源编辑器编辑主资源

文件并保存它而不会丢失条件

#includes特定于名称的资源文件。所以,主资源文件

包括以下内容:


3 TEXTINCLUDE

BEGIN

" ; #include"" apptype.h""

" #ifdef APP_A" //< ---- error

" #include"" app_a.rc""

"#else"

" #include"" app_b.rc""

" #endif"

//其他#includes

" \0"

END


但是,RC在标记的行上产生RC2104错误,并带有消息

未定义的关键字或密钥名称:#ifdef。由于RC通常理解#ifdef我

不明白为什么它抱怨TEXTINCLUDE中的一个。可以有人

解释一下吗?


在同一主题上,这是一个MDI应用程序,每个菜单都有一个菜单

不同的文件类型。我不得不将_all_菜单放在

app-name特定的资源文件中,而这只是因为About ...项目

在帮助菜单上(按照惯例,此项目包括应用程序名称:

"关于AppA ...或关于AppB .. ")。这意味着任何菜单更改必须在两个资源文件中完成。有没有更简单的方法呢?


我使用的是VS .NET 2003.


David
Hello,

In a C++ MFC application I need to conditionally #include one of two additional
resource files in my main resource file because different forms of the
application have different names. I would also like to edit the main resource
file with the IDE''s resource editor and save it without losing the conditional
#includes of the name-specific resource files. So, the main resource file
includes the following:

3 TEXTINCLUDE
BEGIN
"#include ""apptype.h""
"#ifdef APP_A" // <---- error
"#include ""app_a.rc""
"#else"
"#include ""app_b.rc""
"#endif"
// the other #includes
"\0"
END

However, RC is producing an RC2104 error on the marked line with the message
"Undefined keyword or key name: #ifdef". Since RC normally understands #ifdef I
don''t understand why it complains about one in a TEXTINCLUDE. Can someone
explain it?

On the same subject, this is an MDI application with one menu for each of many
different document types. I have had to put _all_ menus in both
app-name-specific resource files, and it''s only because of the "About..." item
on the Help menu (since, by convention, this item includes the application name:
"About AppA..." or "About AppB..."). This means that any menu changes must be
done in both resource files. Is there an easier way to do this?

I am using VS .NET 2003.

David


" David Wilkinson" < no ****** @ effisols.com写信息

新闻:e1 ************** @ TK2MSFTNGP05.phx.gbl ...
"David Wilkinson" <no******@effisols.comwrote in message
news:e1**************@TK2MSFTNGP05.phx.gbl...

David W写道:
David W wrote:

>你好,

在C ++中MFC应用程序我需要有条件地#include我的主资源文件中的两个附加资源文件之一,因为不同形式的应用程序有不同的名称。我还想使用IDE的资源编辑器编辑主要的资源文件并保存它,而不会丢失特定于名称的资源文件的条件#includes。因此,主要的资源文件包括以下内容:

3 TEXTINCLUDE
BEGIN
" #include"" apptype.h""
" #ifdef APP_A" //< ---- error
" #include""" app_a.rc""
" #else"
" #include"" app_b。 rc""
" #endif"
//其他#includes
" \0"
END

然而,RC是在标记的行上产生RC2104错误,并显示消息
未定义的关键字或密钥名称:#ifdef。由于RC通常理解#ifdef
我不明白为什么它抱怨TEXTINCLUDE中的一个。有人可以解释一下吗?

在同一主题上,这是一个MDI应用程序,每个菜单都有一个菜单,用于许多不同的文档类型。我不得不将_all_菜单放在两个特定于应用程序名称的资源文件中,而这只是因为帮助菜单上的关于...
项目(因为,按照惯例,该项目包括
应用程序名称:关于AppA ...或关于AppB ...。这意味着必须在两个资源文件中完成任何菜单更改。有没有更简单的方法来做这个?
>Hello,

In a C++ MFC application I need to conditionally #include one of two
additional resource files in my main resource file because different forms of
the application have different names. I would also like to edit the main
resource file with the IDE''s resource editor and save it without losing the
conditional #includes of the name-specific resource files. So, the main
resource file includes the following:

3 TEXTINCLUDE
BEGIN
"#include ""apptype.h""
"#ifdef APP_A" // <---- error
"#include ""app_a.rc""
"#else"
"#include ""app_b.rc""
"#endif"
// the other #includes
"\0"
END

However, RC is producing an RC2104 error on the marked line with the message
"Undefined keyword or key name: #ifdef". Since RC normally understands #ifdef
I don''t understand why it complains about one in a TEXTINCLUDE. Can someone
explain it?

On the same subject, this is an MDI application with one menu for each of
many different document types. I have had to put _all_ menus in both
app-name-specific resource files, and it''s only because of the "About..."
item on the Help menu (since, by convention, this item includes the
application name: "About AppA..." or "About AppB..."). This means that any
menu changes must be done in both resource files. Is there an easier way to
do this?



不太确定我理解你想要的东西,


Not quite sure I understand what you want here,



我希望了解其中一个:

1.为什么TEXTINCLUDE看起来不像名字所暗示的那样,即简单地

逐字插入引号内的任何文字。

2.如果它确实执行了上述操作,那么插入#ifdef需要什么语法?

I was hoping to understand one of:
1. Why TEXTINCLUDE doesn''t appear to do what the name suggests, i.e., simply
insert verbatim whatever text is inside the quotes.
2. If it does do the above, then what syntax is needed to insert the #ifdef?


但是如果条件编译功能无法实现某些功能<资源编辑器的
,然后我将材料移动到.rc2文件中,在那里你可以根据需要放置#ifdef'而不会破坏资源编辑器。
but if something cannot be accomplished by the conditional compilation feature
of the resource editor, then I move the material into the .rc2 file, where you
can put #ifdef''s as you desire without upsetting the resource editor.



谢谢。我可能会尝试类似的东西,如果我不能得到TEXTINCLUDE来做我想要的b $ b。

Thanks. I might try something like that if I can''t get TEXTINCLUDE to do what I
want.


在我的情况下,这只是一些字符串。
In my case this is just a few strings.



在我的情况下还有更多。

In my case a lot more.


至于关于框,它很容易在OnInitDialog中编写代码来修改

文本。使用AFX_IDS_APP_TITLE获取应用程序标题(这是我放在.rc2文件中的

字符串之一)。
As to the About box, it is easy enough to write code in OnInitDialog to modify
the text. Use AFX_IDS_APP_TITLE to get the app title (this is one of the
strings that I put in the .rc2 file).



关于框是不是问题(这也是重复的,但只有一个

关于框)。问题是导致关于框的所有菜单(其中9个,每个MDI doc一个

类型)。按照惯例,菜单项显示关于

< appname> ...,但由于appname根据#ifdef而有所不同,因此这些菜单

必须重复。


David

The About box isn''t the problem (that''s duplicated as well, but there''s only one
About box). The problem is the all the menus (9 of them, one for each MDI doc
type) that lead to the About box. By convention the menu item says "About
<appname>...", but since the appname varies according to the #ifdef, those menus
have to duplicated.

David


这篇关于#ifdef上出现RC2104错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆