UE5 - BuildTool: How can I set Target.WindowsPlatform.bUpdatedCPPMacro property? - build-tools

I'm trying to use a third party library inside ue5. For it to compile, I need to add the "Zc__cplusplus" option to the compiler.
While going through a file named "VCToolChain.cs" I found out that, the needed option will be included if the variable "Target.WindowsPlatform.bUpdatedCPPMacro" is set to true.
So my question is where and when is this variable set?
Can I set it in some non hacky way?

Related

Is there substitution text syntax for strings in Xcode interface builder UI?

I have an Objective C++ program used to handle the setup of our different applications. Is there a way to use preprocessor defines to create text to be substituted in the strings used by NSTextFieldCell, NSButtonCell?
FOR EXAMPLE, instead of have an NSTextField that says "Options for setting up Foo", there would be a preprocessor macro (GCC_PREPROCESSOR_DEFINITIONS):
MY_PROGRAM_NAME=Bar
and then the text for NSTextField would be:
"Options for setting up $(MY_PROGRAM_NAME)"
Which would then have the desired result: "Options for setting up Bar"
NOTE 1: obviously, I could do the substitution programmatically in code.
Note 2: this is for Xcode 7, so perhaps there isn't a feature like this?
In a word, no. The Xcode nib compiler doesn't perform any kind of variable substitution and—once encoded—all archived property values are static.
However, if this is a "thing" for you application, and there aren't too many view classes involved (say, just NSTextField), it wouldn't be hard to roll your own solution.
I'd consider this approach:
Concoct a simple-to-substitute syntax, a la "Some string {VAR_NAME}".
Define your variables as key/value pairs in a dictionary. Store the
dictionary as an XML file / dictionary in the app bundle.
At app startup, load the dictionary and make it public by putting it in
a global variable or adding it to -[NSUserDefaults registerDefaults:]
Subclass NSTextField (as an example). Override either
-initWithCoder: or -awakeFromNib. In the override, get the string
value of the view object, scan it for substitutions using the public
variable dictionary, and update the string property as appropriate.
In IB, change the class of any NSTextField that needs this feature to
your custom subclass.
Another possible approach would be to have multiple targets in your project and a separate Localizable.strings file for each of these. This of course assumes, that you use Localizable.strings, even if you may support only one language.

Using CompilerMessageAttribute to produce a compiler error, but only in other assemblies

I have a union type that has a single, empty case.
type Default =
| Default
This type has a purpose, but it's not meant to be visible or usable.
Unfortunately, I have to use it in an inline function that does need to be visible. This prevents me from making the type or the case private.
The solution I came up with is using the CompilerMessageAttribute on it to signal an error whenever it's used. This would be fine, but now I can't compile my own assembly because IT uses it.
Is there a way to signal an error only when it's used by an assembly that references my assembly?
Let me reiterate the requirements to make sure I understand them:
The type needs to be public, so that that other assemblies can reference it implicitly via inline.
But if other assemblies reference it explicitly, then that is an error.
I don't know of any way of doing this using standard tooling.
I can see two possible solutions.
If only one calling assembly needs to use the inline function, what about making the type internal and then have the calling assembly be a friend assembly, using the InternalsVisibleToAttribute.
The only other alternative I can think of is security by obscurity. Hide the type in some awkwardly named module and require module qualification. This will stop accidental use of the type, if nothing else.
You could even add a build step to check that no source code references the module name.
[<RequireQualifiedAccessAttribute>]
module ``Dont Use This`` =
type Default =
| Default
let x = ``Dont Use This``.Default
And yes, it's very kludgy.

Accessing hidden private class in Objective-C

How can I access an attribute that's been hidden via:
__attribute__((visibility("hidden")))
I'm trying to access UINavigationItemButtonView, but it seems sometime recent (iOS 7.1?) they've added the above into the header file. Recursively printing the window no longer reveals UINavigationItemButtonView in the view stack either.
So, given a UINavigationBar, how can I access a UINavigationItemButtonView that has been hidden via the above flag?
Printing all the subviews in UINavigationBar doesn't reveal it.
The attribute keyword is simply a message to the compiler, and has nothing to do with the runtime. Using ((visibility("xxx")) only serves to tell the compiler if the given declaration should be "visible" or usable by clients in some other package. visibility("hidden") just means that, despite the public declaration, make this thing invisible to external packages, so that they will not be able to use it. Compiling will fail if you attempt to use this class or method.
If you don't see this class being used in a recursive description, it is likely that this class is no longer used; it certainly isn't because of the attribute statement.
Since it's a private class, you shouldn't. Anything you do to bypass that restriction may result in your application failing the review process. Not to mention that, in general, accessing private and/or hidden API's, classes, instance variables, properties or whatever else it is, is a really good way to make sure your application breaks in the (not too distant) future.

How to change the value of variable in called target in ant

can i change the value of parameter in called target and then retrieve it in the calling target in ant.Probably By refid if there is any other way that is appreciated.
Normally you cannot modify an ant property in ant once it's set, but as oers pointed out in a comment, you can use the Variable task in ant-contrib. You can even override an existing property with a Variable. According to the documentation, you should still use properties in most cases, and only use variables in the cases where you really need to be able to modify a value.
Another workaround is to set additional properties and call the other targets using those properties.

Redeclaration hides member in base class

I am trying to clean up compiler warnings in an application I inherited. One of our classes inherits from TControl. The warning I am getting is "Redeclaration of Changed hides a member in the Base class"
"Changed" is a protected procedure in TControl. The class I am looking at has overridden it with a boolean property
property Changed : Boolean read FChanged write FChanged stored true;
There are a few options I have ruled out already:
Rename from "Changed" to something else. This is not a practical option, as this property is used everywhere in the application.
Hide the warning using compiler directives. I can do this but I would prefer to find out what the warning means and how to correct it.
So my question is:
1) Is this warning actually a problem? What are the implications of "hiding the base member"?
2) How can I remove the compiler warning without renaming the property or hiding the warning?
I am using Delphi 2010
[Edit: There have been a few suggesions of using the refactoring tool to rename the offending property. I have ruled this out as the refactoring tool doesn't work at all on this codebase]
If your own 'Changed' was a procedure as well, you could use the override directive to tell the compiler that you add functionality to the base Changed method in TControl. If your declaration differs or you want for some other reason to break the chain of inheritance, you could specify the reintroduce directive to tell the compiler that you conciously break the chain.
Unfortunately this is not possible with properties, so there is no real solution for your problem, other than
Rename 'Changed' to something else
Hide the warning using directives
Don't inherit from TControl
I would opt for the first option. Since you are using Delphi 2010, you can use the Refactoring tools in Delphi to rename the property thoughout your application, although I would thoroughly check the modifications before making them final, because maybe they will affect the Changed method in the base class as well...

Resources