Build error while using stricmp in Xcode - iphone

I am getting build error while using stricmp to compare two C strings in Xcode.
Error : Implicit declaration of stricmp invalid in C99. What is it means?

What it means is that a declaration of stricmp cannot be found in the headers you have included. Earlier versions of C allowed you to call functions that were not declared in the headers and assumed that they were declared as int function()
stricmp is not in the C or POSIX standards. For iOS look at strcasecmp() as per this SO question

Related

Is Map really a type in Flutter? Unfinished Map declarations break other Map declarations

I understand that in Flutter, I can declare a Map using a map constructor':
eg.
var map_name = new Map();
and then use it:
map_name[key] = value
or using Map literals:
var details = {'Username':'Fede','Password':'pass#123'};
However, I have seen perfectly valid code in Dart such as:
Map<String, int> phoneBook ={
'Fede': 12345678,
'Juli': 5467899,
'Pablo' : 56788654,
};
This kind of declaration can be accepted by the compiler in normal cases:
code accepted by compiler
but (after hours of debugging) I have seen that not finishing the declaration of one map in this way by not assigning a name for it, the compiler (in Android Studio) will yield an error telling that "Map isn't a type" in other valid declarations, even in other files calling that file where the Map declaration was not finished! That is, the error is quite spread.
crashed code
map isnt't a type
In other words, the unfinished declaration of one Map breaks the possibility to declare any other Maps in this way, anywhere linked to that unfinished sentence giving a 'map isn't a type' error. The problem dissappears when you just put a name to the unfinished Map declaration and Maps are treated as types again. So my question is: Are Maps a type for Flutter, or is it just a minor bug?
In your "crashed code" picture, i seen that you have not provide name for second map.Your error is kind of syntax, please provide correct declaration to make its work. I tried your code in my IDE and its working perfectly.The syntax you tried is totally valid and it should working.

UnsafeMutablePointer to expected argument type UnsafeMutablePointer<_> in Swift 3

In the main.swift file, we have a call to our receipt checking system (generated by Receigen). In Swift 2, main.swift read:
startup(Process.argc, UnsafeMutablePointer<UnsafePointer<Int8>>(Process.unsafeArgv))
After upgrading to Swift 3, I've got as far as:
startup(CommandLine.argc, UnsafeMutablePointer<UnsafePointer<Int8>>(CommandLine.unsafeArgv))
which shows the error:
Cannot convert value of type
UnsafeMutablePointer<UnsafeMutablePointer<Int8>?> (aka
UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) to
expected argument type UnsafeMutablePointer<_>
Update: Using the linked question so that it reads:
startup(CommandLine.argc, UnsafeMutableRawPointer(CommandLine.unsafeArgv)
.bindMemory(
to: UnsafeMutablePointer<Int8>.self,
capacity: Int(CommandLine.argc)))
Produces:
Cannot convert value of type UnsafeMutablePointer<Int8>.Type to
expected argument type UnsafePointer<Int8>?.Type (aka
Optional<UnsafePointer<Int8>>.Type)
Where the compiler is referring to the to:UnsafeMutablePointer.
The header for startup looks like:
int startup(int argc, const char * argv[]);
How can I successfully pass the variables to startup in main.swift?
Basically, this is a variant on the problem discussed here:
Xcode 8 beta 6: main.swift won't compile
The problem is that you have an impedance mismatch between the type of CommandLine.unsafeArgv and the type expected by your C function. And you can no longer cast away this mismatch merely by coercing from one mutable pointer type to another. Instead, you have to pivot (as it were) from one type to another by calling bindMemory. And the error message, demanding a Optional<UnsafePointer<Int8>>.Type, tells you what type to pivot to:
startup(
CommandLine.argc,
UnsafeMutableRawPointer(CommandLine.unsafeArgv)
.bindMemory(
to: Optional<UnsafePointer<Int8>>.self,
capacity: Int(CommandLine.argc))
)
That should allow you to compile. Testing on my machine with a stub of startup, it actually runs. But whether it will run on your machine, and whether it is safe, is anybody's guess! This stuff is undeniably maddening...
EDIT The problem with CommandLine.unsafeArgv is fixed in iOS 12 / Xcode 10, so it may be that this problem is fixed too.

How do I reference a datatype defined in a different .swift file?

I'm unable to access a datatype declared in a separate .swift file.
Scenario:
I have two .swift files: a) envSwift.swift and b) mySwift.swift
'envSwift.swift' has my assorted data types, including an enum (which are defined as themselves, outside of any class):
mySwift.swift:
I'm getting the compiler error: "Use of unresolved identifier 'FKPermission'".
How do I use (refer to) a public datatype defined in a different .swift file?
Hint: when I do a copy/paste of enum FKPermission into the top of mySwift.swift & compile, I get the following compiler error: "Invalid redeclaration of 'FKPermission'"; even though I can't access it. So the original enum is detected, but 'unresolved'.
Although you say that both files are in the same target, maybe one of them is also in another target (e.g. your test target)?
That would be leading to exactly the errors you're describing:
1) the 'unresolved identifier' error (compiling the test target)
2) when copy/pasting the declarations - the 'redeclaration' error (compiling the main target).
So perhaps the solution is: add envSwift.swift to your test target, too.

Is it allowed to have two structs with the same name?

I have the following code in some e file:
<'
package my_package;
struct packet {
foo() is {
print "Hello";
};
};
'>
And my top file imports several files, including this one, and at some point it calls the foo() method.
Now, by mistake I added this code:
struct packet {};
in some other file (I just forgot that I already had a struct called “packet”), which is imported by top before the above file.
Strangely, when I tried to load the top file, I got this error:
*** Error: 'p' (of type main::packet) does not have 'foo()' method.
at line 9 in top.e
p.foo();
But why didn’t it fail already on the file that defines foo()?
It has a struct declaration for packet, but packet was already (mistakenly) declared in an earlier file, so why didn’t it give a duplicate type name error? Is it allowed to have two structs with the same name??
Actually, it's not that the main package takes precedence.
But when a type name is used in some file, the same package to which this file belongs, takes precedence.
In this case, the top.e file probably didn't have any "package" statement, so it also belonged to package main.
If top.e had "package my_package", then "packet" in it would resolve to my_package::packet (and not to main::packet), and there would be no error.
You are allowed to have the same name for different structs, but they must be defined in different packages. In your case you first define packet in the my_package package. I'm guessing the other code you added was in some other file that did not have the line package my_package; in it. This means you defined another struct called packet in the main package. This effectively means that you have two different types: my_package::struct and main::struct. In main::packet you didn't define any foo() function (as you can see also from the error message). As Yuti mentions, in your top.e file you probably don't have a package declared, so the main package takes precedence over any other package.
As an exercise, if you change your code in top.e to my_package::packet instead of simply packet it's going to work. You can anyway see something is wrong from the error message. You know you expected my_package::packet, but you were creating a main::packet.
Have a look in the Specman e Language Reference, section 28, Encapsulation Constructs for more info on packages.

Doxygen and Fortran with KIND parameters

I'm using Doxygen to document a Fortran code and I have variables declared such as:
REAL(KIND=8), PARAMETER :: myParam = 1.0_8
but Doxygen gets confused and seems to think REAL is a function and throws:
warning: documented function `real' was not declared or defined.
I have OPTIMIZE_FOR_FORTRAN set to YES so that's not the issue.
Is there a way to rectify this without having to wrap some pre-processor guard around my variables to declare them as REAL without the KIND parameter when building documentation?