What is Xcode's 'Compiler Default' for C++ language settings? - c++

In the Xcode 5 (and probably 4) project settings -
How can we find out what 'Compiler Default' actually resolves to for the Apple LLVM - Language - C++ setting?

According to the "Quick Help Inspector" in Xcode 5.0.2, the current "Compiler Default" is "GNU++98", which corresponds to the compiler option "-std=gnu++98".
It can also be seen in the compiler source code (http://clang.llvm.org/doxygen/CompilerInvocation_8cpp_source.html, line 01057):
01033 if (LangStd == LangStandard::lang_unspecified) {
01034 // Based on the base language, pick one.
01035 switch (IK) {
01036 case IK_None:
01037 case IK_AST:
01038 case IK_LLVM_IR:
01039 llvm_unreachable("Invalid input kind!");
01040 case IK_OpenCL:
01041 LangStd = LangStandard::lang_opencl;
01042 break;
01043 case IK_CUDA:
01044 LangStd = LangStandard::lang_cuda;
01045 break;
01046 case IK_Asm:
01047 case IK_C:
01048 case IK_PreprocessedC:
01049 case IK_ObjC:
01050 case IK_PreprocessedObjC:
01051 LangStd = LangStandard::lang_gnu99;
01052 break;
01053 case IK_CXX:
01054 case IK_PreprocessedCXX:
01055 case IK_ObjCXX:
01056 case IK_PreprocessedObjCXX:
01057 LangStd = LangStandard::lang_gnucxx98;
01058 break;
01059 }
01060 }

Related

what is the correct map with regexp in nginx?

I want to use different builds depends of browser version and device.
For example in "mobile chrome/80+ version" I need to have modern-bundle and on lower versions - legacy-bundle. Bur modern version for desktop is lower than for mobile: "chrome/70+ version" must have modern-bundle and on lower than 70 - legacy-bundle
I tried this code with two maps but finally I always have legacy-bundle instead of modern-bundle
What's wrong there?
map $http_user_request $is_mobile {
default false;
"~*Mobile" true;
}
map "$http_user_request:$is_mobile" $modern_browser {
default "";
"~Chrome\/([8-9][0-9]|\d{3,})\.:true" "modern-bundle";
"~Chrome\/([7-9][0-9]|\d{3,})\.:false" "modern-bundle";
}
I found the answer for my question. Just needed to add one more variable to map
map $http_user_request $is_mobile {
default false;
"~Mobile" true;
}
map "$http_user_request:$is_mobile:$http_user_request" $modern_browser {
default "";
"~Chrome\/([8-9][0-9]|\d{3,})\..*:true:" "modern-bundle";
"~Chrome\/([7-9][0-9]|\d{3,})\..*:false:" "modern-bundle";
}

Rider for UE: build don't have any effect

Not sure if it's a software issue or my incredible programming skills.
I'm using UE4.27 and Rider for UE 2021.2.1 for C++ project. Recently I got some strange bug or something else: some changes in the code do not affect the program in any way. For example, there are old logs (Unable to get Owner Actor, AttackMontageN) that still work fine and new logs (NewLog) that didn't work, but there are no errors while building, crashes or anything like this:
void UMeleeAttackAbility::CommitExecute(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo,
const FGameplayAbilityActivationInfo ActivationInfo)
{
Super::CommitExecute(Handle, ActorInfo, ActivationInfo);
const auto Owner = ActorInfo->OwnerActor.Get();
if (!Owner)
{
UE_LOG(LogPRAbilitySystemBase, Error, TEXT("Unable to get Owner Actor"))
K2_EndAbility();
}
UE_LOG(LogPRAbilitySystemBase, Warning, TEXT("NewLog"));
const int MontageIndex = rand() % 3;
switch(MontageIndex)
{
case 0:
UE_LOG(LogPRAbilitySystemBase, Warning, TEXT("AttackMontage1"));
AttackMontage = AttackMontage1;
break;
case 1:
UE_LOG(LogPRAbilitySystemBase, Warning, TEXT("AttackMontage2"));
AttackMontage = AttackMontage2;
break;
case 2:
UE_LOG(LogPRAbilitySystemBase, Warning, TEXT("AttackMontage3"));
AttackMontage = AttackMontage3;
break;
default:
break;
}
UE_LOG(LogPRAbilitySystemBase, Warning, TEXT("NewLog"));
//...
}
I reverted to one very old commit where this code is completely different, but the results in the logs and character behavior are still the same. Also I'm tried to rebuild current project (in Advanced Build Actions) and do some other obvious things such restarting UE4/Rider, etc. Is it Rider problem or it can be something else?

Error with strided slice in tensorflow lite

I'm facing a problem with tensorflow-lite. I get this error:
Type INT32 (2) not supported.
Node STRIDED_SLICE (number 2) failed to invoke with status 1
What I did was:
I trained a model with MNIST data.
model = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_shape=(28, 28)),
tf.keras.layers.Reshape(target_shape=(28, 28, 1)),
tf.keras.layers.Conv2D(filters=12, kernel_size=(3, 3), activation='relu'),
tf.keras.layers.MaxPooling2D(pool_size=(2, 2)),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(10)
])
I converted the model using integer-only quantization. However, when I invoke the model it
throws that error.
I was looking at the striced_slice.cc and I found this:
switch (output->type) {
case kTfLiteFloat32:
reference_ops::StridedSlice(op_params,
tflite::micro::GetTensorShape(input),
tflite::micro::GetTensorData<float>(input),
tflite::micro::GetTensorShape(output),
tflite::micro::GetTensorData<float>(output));
break;
case kTfLiteUInt8:
reference_ops::StridedSlice(
op_params, tflite::micro::GetTensorShape(input),
tflite::micro::GetTensorData<uint8_t>(input),
tflite::micro::GetTensorShape(output),
tflite::micro::GetTensorData<uint8_t>(output));
break;
case kTfLiteInt8:
reference_ops::StridedSlice(op_params,
tflite::micro::GetTensorShape(input),
tflite::micro::GetTensorData<int8_t>(input),
tflite::micro::GetTensorShape(output),
tflite::micro::GetTensorData<int8_t>(output));
break;
default:
TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.",
TfLiteTypeGetName(input->type), input->type);
So there is not support for int32. I am not really sure how I can handle this kind of problem. Is there any way to change the behavior on this node? Should I do something different in the quantization step?
What I did was:
def representative_data_gen():
for input_value in tf.data.Dataset.from_tensor_slices(train_images).batch(1).take(100):
yield [input_value]
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = representative_data_gen
# Ensure that if any ops can't be quantized, the converter throws an error
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.inference_input_type = tf.int8
converter.inference_output_type = tf.int8
tflite_model = converter.convert()
open("model_int8.tflite", "wb").write(tflite_model)
PD: I'm working with tensorflow-lite to be used in stm32.
Thanks in advance.
When you perform full-integer quantization, your inputs and outputs should be 1-byte long (in your case int8). Give as input int8 values and you will be able to invoke your model.
I worked around this issue simply adding INT32 support to striced_slice.cc.
case kTfLiteFloat32:
reference_ops::StridedSlice(op_params,
tflite::micro::GetTensorShape(input),
tflite::micro::GetTensorData<float>(input),
tflite::micro::GetTensorShape(output),
tflite::micro::GetTensorData<float>(output));
break;
case kTfLiteUInt8:
reference_ops::StridedSlice(
op_params, tflite::micro::GetTensorShape(input),
tflite::micro::GetTensorData<uint8_t>(input),
tflite::micro::GetTensorShape(output),
tflite::micro::GetTensorData<uint8_t>(output));
break;
case kTfLiteInt8:
reference_ops::StridedSlice(op_params,
tflite::micro::GetTensorShape(input),
tflite::micro::GetTensorData<int8_t>(input),
tflite::micro::GetTensorShape(output),
tflite::micro::GetTensorData<int8_t>(output));
break;
case kTfLiteInt32:
reference_ops::StridedSlice(op_params,
tflite::micro::GetTensorShape(input),
tflite::micro::GetTensorData<int8_t>(input),
tflite::micro::GetTensorShape(output),
tflite::micro::GetTensorData<int8_t>(output));
break;
default:
TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.",
TfLiteTypeGetName(input->type), input->type);
return kTfLiteError;
I copied the kTfLiteInt8 case and created a kTfLiteInt32 case.
The idea is since I know the input data is actually int8 type, I simply cast it to int8.
I have tested it in an ESP32 microcontroller. I didn't run a full set of test but with a few samples it worked as expected.
This is a workaround. The real fix should be done in the converter where it fully quantize the model by using TFLITE_BUILTINS_INT8. Somehow, it quantize the float32 types but int32 stays in one of the layers.

light inject - unit testing

I have an c# interface with multiple implementations & each implementation is taking various dependencies object in its constructor.
In order to achieve DI using LightInjector on web api project, Im registering a 'Func' like below & its working as expected but can't able to unit test it.
Any way I can write the below code in unit testable way?
container.RegisterInstance<Func<IHandler, HandlerType, IHandler>>
((handler, type) =>
{
IHandler context = null;
switch (type)
{
case HandlerType.Type0:
context = new Type0(orderHandler, container.GetInstance<IUtilityLogic>());
break;
case HandlerType.Type1:
context = new Type1(orderHandler, container.GetInstance<IUtilityLogic>(), container.GetInstance<IShipmentLogic>());
break;
case HandlerType.Type2:
context = new Type2(orderHandler);
break;
case HandlerType.Type3:
context = new Type3(orderHandler, container.GetInstance<IUtilityLogic>());
break;
case HandlerType.Type4:
context = new Type4(orderHandler, container.GetInstance<IUtilityLogic>(), container.GetInstance<IShipmentLogic>(), container.GetInstance<Func<string, string, ICache>>());
break;
default:
context = null;
break;
}
return context;
});

Remove 'component' word from urls for my custom non mvc component in joomla

I wrote a custom non-mvc component (because i don't know how to make mvc component and now it's grown is size so changing it will take more time which is not possible for me) 'com_group' for my client.
Everything is fine but when it comes to sef urls it gives me urls like mysite/component/group/home and in non sef urls like mysite/index.php?option=com_group&view=home but client wants to remove component word from urls.
I also made a router for my component which remove every parameter correctly but it does not remove component. I also made a menu item for it but it didn't helped me.
Here is my router.php
<?php //error_reporting(E_ALL);
defined ( '_JEXEC' ) or die ();
jimport('joomla.error.profiler');
function GroupBuildRoute(&$query){
$segments = array();
//$query['Itemid'] = 201;
if( isset($query['view']) )
{
$segments[] = $query['view'];
unset( $query['view'] );
};
if( isset($query['pin']) )
{
$segments[] = $query['pin'];
unset( $query['pin'] );
};
return $segments;
}
function GroupParseRoute($segments){
$vars = array();
$app =& JFactory::getApplication();
$menu =& $app->getMenu();
$item =& $menu->getActive();
$items = $menu->getItems('component', 'com_group');
if (!isset($query['Itemid']))
$query['Itemid'] = 180;//$items->id;
// Count segments
$count = count( $segments );
//Handle View and Identifier
switch( $segments['0'] ){
case 'group_page':
$vars['view'] = 'group-pages';
break;
case 'group':
$vars['view'] = 'home';
break;
case 'folow':
$vars['view'] = 'follow';
break;
case 'start':
$vars['view'] = 'start-group';
break;
case 'group_eventplan':
$vars['view'] = 'group-event-plan';
break;
case 'group_member':
$vars['view'] = 'group-members';
break;
case 'manage_subscription':
$vars['view'] = 'manage-subscription';
break;
case 'group_msg':
$vars['view'] = 'group-message';
break;
case 'group_invite':
$vars['view'] = 'invite-friends';
break;
case 'other_group':
$vars['view'] = 'other-groups';
break;
case 'groupinfo':
$vars['view'] = 'group-info';
break;
case 'home':
$vars['view'] = 'group-home';
break;
}
if (!isset($item)) {
$vars['view'] = $segments[0];
$vars['pin'] = $segments[1];
return $vars;
}
if($count==2){
$vars['view'] = $vars['view'];
$vars['pin'] = $segments[1];
return $vars;
}
return $vars;
}
I also want to replace group_msg to group-message also so that new urls should be component/group/group-message/ not component/group/group_msg
I tried Remove component part from sef url, menu item not completely but didn't helped me.
Finally i managed to solve the question by myself. I am mentioning steps taken to help others. (Please write me if you want source code to use it with your project)
Step 1: add a menu item (Joomla Administrator -> Menus ->Menu Manager->Add new Item)
Step 2: The newly added menu item will be provided an id, add this id to all urls of your component like this.
index.php?option=com_your_component_name&Itemid=newly_generated_id
that's it.
The first option I would try is sh404SEF
Good luck!
EDIT
If SEF extensions are not an option for you, perhaps using .htaccess and redirect, something like the following :
RewriteEngine On
Redirect /component/group/home /something-else