Here I'm trying to understand what happens when I run
./hello
#include
Here I'm trying to understand what happens when I run
./hello
#include
The std::str documentation is also quite good.
// Create a string from a literal
let hello: &'static str = "Hello!";
let hello2: &str = "Hello!";
I found understanding Rust types really confusing, so I wrote up a small tutorial for myself in an attempt to understand some of them. This is by no means exhaustive. There is a types section in the manual, but it has nowhere near enough examples.
I'm not talking about managed pointers (@
) at all. A lot of the difficulty with Rust types is that the language is constantly changing, so this will likely be out of date soon.
First, a few preliminaries: it's easier to play with types if you have a REPL and can interactively check the types of objects. This isn't really possible in Rust, but there are workarounds.
.file "blah.rc" | |
.text | |
.globl _ZN5stdio12clear_screen19h458d5a7d48ef5f58aj4v0.0E | |
.align 16, 0x90 | |
.type _ZN5stdio12clear_screen19h458d5a7d48ef5f58aj4v0.0E,@function | |
_ZN5stdio12clear_screen19h458d5a7d48ef5f58aj4v0.0E: | |
.cfi_startproc | |
cmpl %gs:48, %esp | |
ja .LBB0_2 | |
pushl $8 |
I'm trying to set up keycode handling in my kernel, and I'm having a strange problem with array indexing.
When I run this code, and press 1
several times, it prints |2C |2C |2C |2C |2C |2C |2C |2C |2C
.
I am expecting it to print |2C2|2C2|2C2|2C2|2C2|2C2|2C2|2C2|2C2|
.
2
is printed by putc(NUMS[2])
C
is printed by putc(65 + keycode)
. This implies that keycode == 2
, since 65 is 'A' |
is printed by putc(NUMS[keycode])
and a delimiter. I would expect this to print 2|
. But no.<html> | |
<head> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$('h2').html("Hello, Arielle!"); | |
}) | |
</script> | |
</head> | |
<body> |
These are some notes from reading Ian Lance Taylor's 20-part essay on linkers. Prettified version on gist.io.
I'm not going to describe the basics of what a linker does because I know already. I talk a little about linkers in How to call Rust from assembly, and I found this Beginner's guide to linkers pretty helpful. Parts [1] and [2] of the essay also discuss "what's a linker?".
We're going to be dealing with a "Hello, world!" program. Just one. There's going to be a bunch of fruit for discussion here. I'm going to be assuming you're on Linux, because we're gonna be talking about ELF and Macs use Mach-O and I don't know anything about Mach-O.
#include <stdio.h>
char *penguin = "Penguin";
char array[5] = {'a', 'b', 'c', 'd', 'e'};
I want to compile a 32-bit "Hello, world!" statically-linked ELF binary for Linux, and try to run it in my operating system. I'm trying to understand what I'll have to do. The goal is to get everything just barely working, so that it will print the string to the screen and not crash the whole system.
I asked a question about this a little while ago, and got lots of helpful responses. Now I need to make it a bit more concrete, though.
diff --git a/core/lib.rs b/core/lib.rs | |
index 5d4bb69..a18ce21 100644 | |
--- a/core/lib.rs | |
+++ b/core/lib.rs | |
@@ -15,7 +15,7 @@ | |
#[crate_type = "rlib"]; | |
#[feature(macro_rules)]; | |
-#[cfg(libc)] | |
+#[cfg(libc, pthread)] |