Skip to content

macos: pipe input doesn't work with scanf #21

@Emoun

Description

@Emoun

To send input to a program's stdin running on the simulator, we can use piping: echo "some input" | pasim a.out.

Doing this on macos doesn't work. Example program:

#include <stdio.h>
int main() {
	int x ;
	scanf("%d", &x);
	printf("Output: %d\n", x + 2);
	return 0;
}

After compiling with patmos-clang -O2 main.c, and running using echo "2" | pasim a.out, we would expect it to output Output: 4, but instead we get Output: 2.
Clearly scanf is not working correctly.
Running the same program and commands on ubuntu outputs the expected string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions