Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] including std/core and std/mem at in the same file crashes imhex #1641

Closed
1 task done
Calcoph opened this issue Apr 28, 2024 · 6 comments · Fixed by WerWolv/Documentation#18
Closed
1 task done
Labels
bug Something isn't working

Comments

@Calcoph
Copy link

Calcoph commented Apr 28, 2024

Operating System

Windows

What's the issue you encountered?

If I try to include both std/core.pat and std/mem.pat imhex crashes.

How can the issue be reproduced?

  1. type in the pattern editor:
#include <std/core.pat>
#include <std/mem.pat>
  1. Press "run".

ImHex Version

1.33.0 a7033b6

ImHex Build Type

  • Nightly or built from sources

Installation type

MSI

Additional context?

No response

@Calcoph Calcoph added the bug Something isn't working label Apr 28, 2024
@glpnk
Copy link

glpnk commented Apr 28, 2024

Use import statements now

import std.core;
import std.mem;

Also, segfault happens on Linux too

@paxcut
Copy link
Contributor

paxcut commented Apr 28, 2024

I have known about problems including those two files for a while which is caused by all files using import internally, but it didn't crash imhex before.

@C3pa
Copy link

C3pa commented Jul 10, 2024

Ok, on Windows 10, ImHex v1.35.4 #includeing both headers won't crash ImHex but triggers a stream of errors.

@paxcut
Copy link
Contributor

paxcut commented Jul 10, 2024

thats normal because include and import use different pragma once systems so they can't be mixed. Because all headers use import internally when you include core it imports mem so when you include mem you get duplicate errors.

@C3pa
Copy link

C3pa commented Jul 10, 2024

Ok, so is it now recommended to only ever use import with built-in libraries?

@paxcut
Copy link
Contributor

paxcut commented Jul 10, 2024

All the headers that are installed with ImHex use import internally so it makes sense to use import in order to use them to avoid problems like the one presented here.

If you make your own headers to use in your patterns then it depends on what features you want to use. if you want to use preprocessor features like #define or #ifdef then you need to use include because import doesn't propagate macro definitions. import uses the as syntax to create namespace aliases but #define can do the same and even more. Both systems have their pros and cons and it is a pity that they can't be used at the same time, but the way they are both designed makes interaction impossible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants