When I compile the glucose SAT solver on Mac, I get the following compile-time errors when compiling glucose 3.0. How do I avoid these errors?
~/acl2/glucose-3.0/simp$ make
Making dependencies
Compiling: /Users/me/acl2/glucose-3.0/simp/Main.o
In file included from /Users/me/acl2/glucose-3.0/simp/Main.cc:39:
In file included from /Users/me/acl2/glucose-3.0/simp/../core/Dimacs.h:27:
/Users/me/acl2/glucose-3.0/simp/../core/SolverTypes.h:58:16: error:
friend declaration specifying a default argument must be a definition
friend Lit mkLit(Var var, bool sign = false);
^
<snip>
6 errors generated.
make: *** [/Users/me/acl2/glucose-3.0/simp/Main.o] Error 1
~/acl2/glucose-3.0/simp$
Credit goes to Marijn Heule for this solution:
Modify your glucose source code to accommodate the following changes:
bash$ diff SolverTypes.h
~/Downloads/glucose-3.0/core/SolverTypes.h
58c58
< // friend Lit mkLit(Var var, bool sign = false);
---
> friend Lit mkLit(Var var, bool sign = false);
66c66
< inline Lit mkLit (Var var, bool sign = false) { Lit p; p.x =
var + var + (int)sign; return p; }
---
> inline Lit mkLit (Var var, bool sign) { Lit p; p.x = var + var + (int)sign; return p; }
The top (<) is the Mac version, while the bottom (>) is the default source.
Related
I have successfully made a level with a Terrain, a Rigidbody FPS Controller from Standard Assets -> Characters and some other GameObjects. I now need to save my system so I have started to google file IO for UnityScript. I have found some examples but they return compiler errors (details below).
OS is Windows 10 64-bit. Unity version is 5.5.1f1 64-bit. Code editor is Visual Studio 2015, line endings corrected to Windows line endings. Language is UnityScript. Code I have used:
#pragma strict
import System;
import System.IO;
var Filename : String = "save.ini";
private var rwfile : StreamWriter;
var x;
var y;
var z;
var Player : GameObject;
private var startTime : int;
private var timer1 : int;
function TimerSet() {startTime = Time.time;}
function TimerUpdate() {
timer1 = Time.time;
if(timer1 > 60) {
Debug.Log("Saving");
Write();
TimerSet();}}
function WriterSetup() {
Debug.Log("File Writer setup...");
if (!File.Exists(Filename)) {
rwfile = File.CreateText(Filename);}
Debug.Log("File Writer configured sucsessfully");}
function Write() {
rwfile = File.CreateText(Filename);
x = Player.transform.position.x;
y = Player.transform.position.y;
z = Player.transform.position.z;
rwfile.WriteLine(x);
rwfile.WriteLine(y);
rwfile.WriteLine(z);
rwfile.Close();}
function Start() {Debug.Log("Saver Script Setup");
WriterSetup();
TimerSet();}
function Update() {TimerUpdate();}
My error:
Your error is telling you that it dosen't know what OpenText is. I don't see in your code anything about a function called OpenText, so i guess you were trying to use the File.OpenText function so you should change this line
rwfile = OpenText(Filename);
To this
rwfile = File.OpenText(Filename);
Also for the other errors you need to assigne your rwfile to a StreamWriter
private var rwfile : StreamWriter;
You should also change your Write function for this:
function Write() {
x = Player.transform.position.x;
y = Player.transform.position.y;
z = Player.transform.position.z;
using (rwfile = File.CreateText(Filename))
{
rwfile.WriteLine(x);
rwfile.WriteLine(y);
rwfile.WriteLine(z);
rwfile.Close();
}
}
I am learning how to develop a Frama-C plugin. After reading the Frama-C Developer manual and doing the CFG plugin example, I tried to do a basic script that prints all annotations in a C file. I came up with this:
open Cil_types
class print_annot out = object
inherit Visitor.frama_c_inplace
method vstmt_aux s =
let annots = Annotations.code_annot s in
let anleng = List.length annots in
if anleng <= 0 then Format.fprintf out "Empty List\n"
else
Format.fprintf out "Number of Annotations: %d\n" anleng;
List.iter (fun annot -> Format.fprintf out " -> s%d\n" annot.annot_id) annots;
Cil.DoChildren
end
let run () =
let chan = open_out "annots.out" in
let fmt = Format.formatter_of_out_channel chan in
Visitor.visitFramacFileSameGlobals (new print_annot fmt) (Ast.get());
close_out chan
let () = Db.Main.extend run
It always says the list is empty even when the input file has ACSL annotations and never prints the annotations id. What am I doing wrong?
Edit:
An example with the following code:
/*# requires y >= 0;
# ensures \result >= 0;
*/
int g(int y){
int x=0;
if(y>0){
x=100;
x=x+50;
x=x-100;
}else{
x = x - 150;
x=x-100;
x=x+100;
}
return x;
}
void main(){
int a = g(0);
}
And invoking frama-c with:
$ frama-c -load-script annot_script.ml condi.c
Gives the following output:
Empty List
Empty List
Empty List
Empty List
Empty List
Empty List
Empty List
Empty List
Empty List
Empty List
Empty List
In your example, none of the annotations are attached to a statement. The requires and the ensures are part of a function contract and are attached to the function g, not to any statement of g.
An annotation that would be attached to a statement would for instance be /*# assert x == 150; */ after the line x=x+50;.
If I modify condi.c to insert this assertion, then with the same commandline, I get:
Empty List
Empty List
Empty List
Empty List
Number of Annotations: 1
-> s1
Empty List
Empty List
Empty List
Empty List
Empty List
Empty List
Empty List
It seems that your script is working as expected, for a value of “expected” that corresponds to printing annotations attached to statements.
I just update Web essentials and Typescript to new version.
Result that my project don't work anymore.
Here's my typescript code:
/// <reference path="DefinitelyTyped/jqueryui.d.ts" />
/// <reference path="DefinitelyTyped/jquery-datatable.d.ts" />
import Common = module("Common");
import GMap = module("GMap");
declare var $: JQueryStatic;
export class Polygon extends GMap.Polygon {
Before update my generated code (that worked) was:
var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
define(["require", "exports", "GMap", "Common"], function(require, exports, __GMap__, __Common__) {
var GMap = __GMap__;
var Common = __Common__;
var Polygon = (function (_super) {
__extends(Polygon, _super);
function Polygon() {
_super.apply(this, arguments);
}
Now it look-like:
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Common = require("./Common");
var GMap = require("./GMap");
var Polygon = (function (_super) {
__extends(Polygon, _super);
In my console I have this error:
Uncaught Error: Module name "Common" has not been loaded yet for context: _. Use require([])
I try to add Common in the config. But before update It s just working fine.
Anyone can help me, maybe something need to be change in my code to have back my project working.
Thanks,
Jérôme
UPDATE
I just see that is due to Web Essentials 2.9, I don't have anymore the option to specify compiler option for amd module.
I just remove the extension and install back the version 2.7:
http://vswebessentials.com/nightly/webessentials2012-2.7.vsix
I would just add to this that Web Essentials does indeed support AMD modules in version 2.8 but that the option has gone missing in 2.9 - check out the comments on the download page.
You'll find the setting (in 2.8 or below) in...
Tools > Options > Web Essentials > TypeScript > "Use the AMD module"
You need to compile with the amd option. i.e.
tsc yourfile.ts --module "amd"
It defaults to "commonjs" which is the output that you are seeing at the moment.
I am new to python, I have looked at boost python, and it looks very
impressive. However going through the introduction I can not find
any examples where, vector of objects are returned as python list/tuples.
i.e Take this example, I want to expose class X, Cont and all its functions.
critical bit being return a vector of X's or strings to python
class X {};
class Cont {
.....
// how can this be exposed using boost python
const std::vector<X>& const_ref_x_vec() const { return x_vec_;}
std::vector<X> value_x_vec() const { return x_vec;}
const std::vector<std::string>& const_ref_str_vec() const { return str_vec_;}
std::vector<std::string> value_str_vec() const { return str_vec_; }
...
private:
std::vector<X> x_vec_;
std::vector<std::string> str_vec_;
};
My own fruitless attempt at trying to expose the functions like
const_ref_x_vec(), value_x_vec(),etc just leads to compile errors.
from googling around I have not seen any example that support returning vectors
by value or reference. Is this even possible with boost python?
are there any workarounds ? should I be using SWIG for this case ?
Any help appreciated.
Avtar
Autopulated's reason was essentially correct, but the code was more complicated then necessary.
The vector_indexing_suite can do all that work for you:
class_< std::vector<X> >("VectorOfX")
.def(vector_indexing_suite< std::vector<X> >() )
;
There is a map_indexing_suite as well.
Because you can't expose template types to python you have to explicitly expose each sort of vector that you want to use, for example this is from my code:
Generic template to wrap things:
namespace bp = boost::python;
inline void IndexError(){
PyErr_SetString(PyExc_IndexError, "Index out of range");
bp::throw_error_already_set();
}
template<class T>
struct vec_item{
typedef typename T::value_type V;
static V& get(T& x, int i){
static V nothing;
if(i < 0) i += x.size();
if(i >= 0 && i < int(x.size())) return x[i];
IndexError();
return nothing;
}
static void set(T& x, int i, V const& v){
if(i < 0) i += x.size();
if(i >= 0 && i < int(x.size())) x[i] = v;
else IndexError();
}
static void del(T& x, int i){
if(i < 0) i += x.size();
if(i >= 0 && i < int(x.size())) x.erase(x.begin() + i);
else IndexError();
}
static void add(T& x, V const& v){
x.push_back(v);
}
};
Then, for each container:
// STL Vectors:
// LineVec
bp::class_< std::vector< Line > >("LineVec")
.def("__len__", &std::vector< Line >::size)
.def("clear", &std::vector< Line >::clear)
.def("append", &vec_item< std::vector< Line > >::add,
bp::with_custodian_and_ward<1, 2>()) // let container keep value
.def("__getitem__", &vec_item< std::vector< Line > >::get,
bp::return_value_policy<bp::copy_non_const_reference>())
.def("__setitem__", &vec_item< std::vector< Line > >::set,
bp::with_custodian_and_ward<1,2>()) // to let container keep value
.def("__delitem__", &vec_item< std::vector< Line > >::del)
.def("__iter__", bp::iterator< std::vector< Line > >())
;
// ...
A similar approach is possible for std::map.
I used lots of help from wiki.python.org when writing this.
Hy,
I expanding an existing specman test where some code like this appears:
struct dataset {
!register : int (bits:16);
... other members
}
...
data : list of dataset;
foo : dataset;
gen foo;
foo.register = 0xfe;
... assign other foo members ...
data.push(foo.copy());
is there a way to assign to the members of the struct in one line? like:
foo = { 0xff, ... };
I currently can't think of a direct way of setting all members as you want, but there is a way to initialize variables (I'm not sure if it works on struct members as well). Anyway something like the following may fit for you:
myfunc() is {
var foo : dataset = new dataset with {
.register = 0xff;
.bar = 0xfa;
}
data.push(foo.copy());
}
You can find more information about new with help new struct from the specman prompt.
Hope it helps!
the simple beuty of assigning fields by name is one language feature i've always found usefull , safe to code and readable.
this is how i'd go about it:
struct s {
a : int;
b : string;
c : bit;
};
extend sys {
ex() is {
var s := new s with {.a = 0x0; .b = "zero"; .c = 0;};
};
run() is also {
var s;
gen s keeping {.a == 0x0; .b == "zero"; .c == 0;};
};
};
i even do data.push(new dataset with {.reg = 0xff; bar = 0x0;}); but you may raise the readablity flag if you want.
warning: using unpack() is perfectly correct (see ross's answer), however error prone IMO. i recommend to verify (with code that actually runs) every place you opt to use unpack().
You can directly use the pack and unpack facility of Specman with "physical fields" ( those instance members prefixed with the modifier %).
Example:
define FLOODLES_WIDTH 47;
type floodles_t : uint(bits:FLOODLES_WIDTH);
define FLABNICKERS_WIDTH 28;
type flabnickers_t : uint(bits:FLABNICKERS_WIDTH);
struct foo_s {
%!floodle : floodles_t;
%!flabnicker : flabnickers_t;
};
extend sys {
run() is also {
var f : foo_s = new;
unpack(packing.low,64'hdeadbeefdeadbeef,f);
print f;
unpack(packing.low,64'hacedacedacedaced,f);
print f;
};
setup() is also {
set_config(print,radix,hex);
};
};
When this run, it prints:
Loading /nfs/pdx/home/rbroger1/tmp.e ...
read...parse...update...patch...h code...code...clean...
Doing setup ...
Generating the test using seed 1...
Starting the test ...
Running the test ...
f = foo_s-#0: foo_s of unit: sys
---------------------------------------------- #tmp
0 !%floodle: 0x3eefdeadbeef
1 !%flabnicker: 0x001bd5b
f = foo_s-#0: foo_s of unit: sys
---------------------------------------------- #tmp
0 !%floodle: 0x2cedacedaced
1 !%flabnicker: 0x00159db
Look up packing, unpacking, physical fields, packing.low, packing.high in your Specman docs.
You can still use physical fields even if the struct doesn't map to the DUT. If your struct is already using physical fields for some other purpose then you'll need to pursue some sort of set* method for that struct.